mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Added a test for issue #808
This commit is contained in:
		| @@ -30,13 +30,6 @@ struct JsonVariantData { | ||||
|     content.asFloat = value; | ||||
|   } | ||||
|  | ||||
|   void setInteger(JsonInteger value) { | ||||
|     if (value > 0) | ||||
|       setPostiveInteger(static_cast<JsonUInt>(value)); | ||||
|     else | ||||
|       setNegativeInteger(static_cast<JsonUInt>(-value)); | ||||
|   } | ||||
|  | ||||
|   void setNegativeInteger(JsonUInt value) { | ||||
|     type = JSON_NEGATIVE_INTEGER; | ||||
|     content.asInteger = value; | ||||
|   | ||||
| @@ -87,6 +87,14 @@ TEST_CASE("deserializeJson(DynamicJsonDocument&)") { | ||||
|     REQUIRE(doc.as<bool>() == false); | ||||
|   } | ||||
|  | ||||
|   SECTION("0") { | ||||
|     DeserializationError err = deserializeJson(doc, "0"); | ||||
|     REQUIRE(err == DeserializationError::Ok); | ||||
|     REQUIRE(doc.is<int>() == true); | ||||
|     REQUIRE(doc.as<int>() == 0); | ||||
|     REQUIRE(doc.as<std::string>() == "0");  // issue #808 | ||||
|   } | ||||
|  | ||||
|   SECTION("NaN") { | ||||
|     DeserializationError err = deserializeJson(doc, "NaN"); | ||||
|     REQUIRE(err == DeserializationError::Ok); | ||||
|   | ||||
| @@ -45,6 +45,10 @@ TEST_CASE("serializeJson(JsonVariant)") { | ||||
|     check(3.1415927, "3.1415927"); | ||||
|   } | ||||
|  | ||||
|   SECTION("Zero") { | ||||
|     check(0, "0"); | ||||
|   } | ||||
|  | ||||
|   SECTION("Integer") { | ||||
|     check(42, "42"); | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user