Kaynağa Gözat

Test casting a JsonValue to a bool

Benoit Blanchon 11 yıl önce
ebeveyn
işleme
028ff6676e

+ 5 - 0
JsonGenerator/JsonValue.h

@@ -59,6 +59,11 @@ namespace ArduinoJson
                 content.asDouble = value;
                 content.asDouble = value;
             }
             }
 
 
+            operator bool()
+            {
+                return content.asBool;
+            }
+
             operator const char*()
             operator const char*()
             {
             {
                 return "";
                 return "";

+ 6 - 0
JsonGeneratorTests/JsonValue_Cast_Tests.cpp

@@ -34,6 +34,12 @@ namespace JsonGeneratorTests
             setValueAndCheckCast(42L);
             setValueAndCheckCast(42L);
         }
         }
 
 
+        TEST_METHOD(Bool)
+        {
+            setValueAndCheckCast(true);
+            setValueAndCheckCast(false);
+        }
+
     private:
     private:
 
 
         template<typename T>
         template<typename T>