mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Fix call of overloaded 'swap(...)' is ambiguous (fixes #1678)
				
					
				
			This commit is contained in:
		| @@ -6,9 +6,9 @@ | ||||
| #include <stdlib.h>  // malloc, free | ||||
| #include <catch.hpp> | ||||
| #include <sstream> | ||||
| #include <utility> | ||||
|  | ||||
| using ARDUINOJSON_NAMESPACE::addPadding; | ||||
| using ARDUINOJSON_NAMESPACE::move; | ||||
|  | ||||
| class SpyingAllocator { | ||||
|  public: | ||||
| @@ -78,7 +78,7 @@ TEST_CASE("BasicJsonDocument") { | ||||
|       BasicJsonDocument<SpyingAllocator> doc1(4096, log); | ||||
|       doc1.set(std::string("The size of this string is 32!!")); | ||||
|  | ||||
|       BasicJsonDocument<SpyingAllocator> doc2(move(doc1)); | ||||
|       BasicJsonDocument<SpyingAllocator> doc2(std::move(doc1)); | ||||
|  | ||||
|       REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!"); | ||||
|       REQUIRE(doc1.as<std::string>() == "null"); | ||||
| @@ -111,7 +111,7 @@ TEST_CASE("BasicJsonDocument") { | ||||
|       doc1.set(std::string("The size of this string is 32!!")); | ||||
|       BasicJsonDocument<SpyingAllocator> doc2(8, log); | ||||
|  | ||||
|       doc2 = move(doc1); | ||||
|       doc2 = std::move(doc1); | ||||
|  | ||||
|       REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!"); | ||||
|       REQUIRE(doc1.as<std::string>() == "null"); | ||||
|   | ||||
| @@ -19,6 +19,7 @@ add_executable(JsonDocumentTests | ||||
| 	size.cpp | ||||
| 	StaticJsonDocument.cpp | ||||
| 	subscript.cpp | ||||
| 	swap.cpp | ||||
| ) | ||||
|  | ||||
| add_test(JsonDocument JsonDocumentTests) | ||||
|   | ||||
							
								
								
									
										13
									
								
								extras/tests/JsonDocument/swap.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								extras/tests/JsonDocument/swap.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| #include <ArduinoJson.h> | ||||
|  | ||||
| #include <catch.hpp> | ||||
| #include <utility> | ||||
|  | ||||
| using namespace std; | ||||
|  | ||||
| TEST_CASE("std::swap") { | ||||
|   SECTION("DynamicJsonDocument*") { | ||||
|     DynamicJsonDocument *p1, *p2; | ||||
|     swap(p1, p2);  // issue #1678 | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user