mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			577 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			577 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| // ArduinoJson - arduinojson.org
 | |
| // Copyright Benoit Blanchon 2014-2020
 | |
| // MIT License
 | |
| 
 | |
| #include <ArduinoJson.h>
 | |
| #include <catch.hpp>
 | |
| 
 | |
| using namespace ARDUINOJSON_NAMESPACE;
 | |
| 
 | |
| TEST_CASE("ElementProxy::size()") {
 | |
|   DynamicJsonDocument doc(4096);
 | |
|   doc.addElement();
 | |
|   ElementProxy<JsonDocument&> ep = doc[0];
 | |
| 
 | |
|   SECTION("returns 0") {
 | |
|     REQUIRE(ep.size() == 0);
 | |
|   }
 | |
| 
 | |
|   SECTION("as an array, returns 2") {
 | |
|     ep.add(1);
 | |
|     ep.add(2);
 | |
|     REQUIRE(ep.size() == 2);
 | |
|   }
 | |
| 
 | |
|   SECTION("as an object, returns 2") {
 | |
|     ep["a"] = 1;
 | |
|     ep["b"] = 2;
 | |
|     REQUIRE(ep.size() == 2);
 | |
|   }
 | |
| }
 |