mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Fix inconsistent pool size in BasicJsonDocument's copy constructor
				
					
				
			This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| #include <ArduinoJson.h> | ||||
|  | ||||
| #include <catch.hpp> | ||||
| #include <string> | ||||
| #include <utility> | ||||
|  | ||||
| using namespace std; | ||||
| @@ -10,4 +11,17 @@ TEST_CASE("std::swap") { | ||||
|     DynamicJsonDocument *p1, *p2; | ||||
|     swap(p1, p2);  // issue #1678 | ||||
|   } | ||||
|  | ||||
|   SECTION("DynamicJsonDocument") { | ||||
|     DynamicJsonDocument doc1(0x10), doc2(0x20); | ||||
|     doc1.set("hello"); | ||||
|     doc2.set("world"); | ||||
|  | ||||
|     swap(doc1, doc2); | ||||
|  | ||||
|     CHECK(doc1.capacity() == 0x20); | ||||
|     CHECK(doc1.as<string>() == "world"); | ||||
|     CHECK(doc2.capacity() == 0x10); | ||||
|     CHECK(doc2.as<string>() == "hello"); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user