mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	as<bool>()
This commit is contained in:
		| @@ -349,4 +349,15 @@ TEST_CASE("JsonVariant::as()") { | ||||
|  | ||||
|     CHECK(variant.as<std::string>() == "hello"); | ||||
|   } | ||||
|  | ||||
|   SECTION("linked bool") { | ||||
|     StaticJsonDocument<128> doc2; | ||||
|     variant.link(doc2); | ||||
|  | ||||
|     doc2.set(true); | ||||
|     CHECK(variant.as<bool>() == true); | ||||
|  | ||||
|     doc2.set(false); | ||||
|     CHECK(variant.as<bool>() == false); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -47,6 +47,8 @@ inline bool VariantData::asBoolean() const { | ||||
|       return _content.asFloat != 0; | ||||
|     case VALUE_IS_NULL: | ||||
|       return false; | ||||
|     case VALUE_IS_POINTER: | ||||
|       return _content.asPointer->asBoolean(); | ||||
|     default: | ||||
|       return true; | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user