mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Test casting a JsonValue to a JsonArray
This commit is contained in:
		| @@ -89,6 +89,11 @@ namespace ArduinoJson | ||||
|                 return content.asLong; | ||||
|             } | ||||
|  | ||||
|             operator Printable&() | ||||
|             { | ||||
|                 return *content.asPrintable; | ||||
|             } | ||||
|  | ||||
|             size_t printTo(Print& p) const | ||||
|             { | ||||
|                 // handmade polymorphism | ||||
|   | ||||
| @@ -6,6 +6,7 @@ | ||||
| #include "CppUnitTest.h" | ||||
| #include "StringBuilder.h" | ||||
| #include "JsonValue.h" | ||||
| #include "JsonArray.h" | ||||
|  | ||||
| using namespace Microsoft::VisualStudio::CppUnitTestFramework; | ||||
| using namespace ArduinoJson::Generator; | ||||
| @@ -45,6 +46,12 @@ namespace JsonGeneratorTests | ||||
|             setValueAndCheckCast(42L); | ||||
|         } | ||||
|  | ||||
|         TEST_METHOD(Array) | ||||
|         { | ||||
|             JsonArray<2> array; | ||||
|             setValueAndCheckCast(array); | ||||
|         } | ||||
|  | ||||
|         TEST_METHOD(String) | ||||
|         { | ||||
|             setValueAndCheckCast("hello"); | ||||
| @@ -59,5 +66,13 @@ namespace JsonGeneratorTests | ||||
|             T actual = value; | ||||
|             Assert::AreEqual(expected, actual); | ||||
|         } | ||||
|  | ||||
|         template<int N> | ||||
|         void setValueAndCheckCast(JsonArray<N>& expected) | ||||
|         { | ||||
|             value = expected; | ||||
|             Printable& actual = value; | ||||
|             Assert::AreEqual((void*) &expected, (void*) &actual); | ||||
|         } | ||||
|     }; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user