mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Fixed JsonVariant::is<int>() that returned true for empty strings
				
					
				
			This commit is contained in:
		| @@ -5,6 +5,7 @@ HEAD | ||||
| ---- | ||||
|  | ||||
| * Improved float serialization when `-fsingle-precision-constant` is used | ||||
| * Fixed `JsonVariant::is<int>()` that returned true for empty strings | ||||
|  | ||||
| v5.13.2 | ||||
| ------- | ||||
|   | ||||
| @@ -10,10 +10,10 @@ namespace ArduinoJson { | ||||
| namespace Internals { | ||||
|  | ||||
| inline bool isInteger(const char* s) { | ||||
|   if (!s) return false; | ||||
|   if (!s || !*s) return false; | ||||
|   if (issign(*s)) s++; | ||||
|   while (isdigit(*s)) s++; | ||||
|   return *s == '\0'; | ||||
| } | ||||
| } | ||||
| } | ||||
| }  // namespace Internals | ||||
| }  // namespace ArduinoJson | ||||
|   | ||||
| @@ -12,6 +12,10 @@ TEST_CASE("isInteger()") { | ||||
|     REQUIRE_FALSE(isInteger(NULL)); | ||||
|   } | ||||
|  | ||||
|   SECTION("Empty String") { | ||||
|     REQUIRE_FALSE(isInteger("")); | ||||
|   } | ||||
|  | ||||
|   SECTION("FloatNotInteger") { | ||||
|     REQUIRE_FALSE(isInteger("3.14")); | ||||
|     REQUIRE_FALSE(isInteger("-3.14")); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user