mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			628 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			628 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| // ArduinoJson - https://arduinojson.org
 | |
| // Copyright © 2014-2023, Benoit BLANCHON
 | |
| // MIT License
 | |
| 
 | |
| #include <ArduinoJson.h>
 | |
| #include <catch.hpp>
 | |
| 
 | |
| TEST_CASE("JsonVariant::size()") {
 | |
|   DynamicJsonDocument doc(4096);
 | |
|   JsonVariant variant = doc.to<JsonVariant>();
 | |
| 
 | |
|   SECTION("unbound reference") {
 | |
|     JsonVariant unbound;
 | |
| 
 | |
|     CHECK(unbound.size() == 0);
 | |
|   }
 | |
| 
 | |
|   SECTION("int") {
 | |
|     variant.set(42);
 | |
| 
 | |
|     CHECK(variant.size() == 0);
 | |
|   }
 | |
| 
 | |
|   SECTION("string") {
 | |
|     variant.set("hello");
 | |
| 
 | |
|     CHECK(variant.size() == 0);
 | |
|   }
 | |
| 
 | |
|   SECTION("object") {
 | |
|     variant["a"] = 1;
 | |
|     variant["b"] = 2;
 | |
| 
 | |
|     CHECK(variant.size() == 2);
 | |
|   }
 | |
| }
 |