mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Fixed MemberProxy::set(char[]) not duplicating the string (fixes #1191)
This commit is contained in:
		| @@ -23,4 +23,12 @@ TEST_CASE("ElementProxy::add()") { | ||||
|  | ||||
|     REQUIRE(doc.as<std::string>() == "[[\"world\"]]"); | ||||
|   } | ||||
|  | ||||
|   SECTION("set(char[])") { | ||||
|     char s[] = "world"; | ||||
|     ep.add(s); | ||||
|     strcpy(s, "!!!!!"); | ||||
|  | ||||
|     REQUIRE(doc.as<std::string>() == "[[\"world\"]]"); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -22,4 +22,12 @@ TEST_CASE("ElementProxy::set()") { | ||||
|  | ||||
|     REQUIRE(doc.as<std::string>() == "[\"world\"]"); | ||||
|   } | ||||
|  | ||||
|   SECTION("set(char[])") { | ||||
|     char s[] = "world"; | ||||
|     ep.set(s); | ||||
|     strcpy(s, "!!!!!"); | ||||
|  | ||||
|     REQUIRE(doc.as<std::string>() == "[\"world\"]"); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -22,4 +22,12 @@ TEST_CASE("MemberProxy::set()") { | ||||
|  | ||||
|     REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}"); | ||||
|   } | ||||
|  | ||||
|   SECTION("set(char[])") {  // issue #1191 | ||||
|     char s[] = "world"; | ||||
|     mp.set(s); | ||||
|     strcpy(s, "!!!!!"); | ||||
|  | ||||
|     REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}"); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user