mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Removed StaticJsonArray and DynamicJsonArray. Removed StaticJsonObject and DynamicJsonObject. Removed StaticJsonVariant and DynamicJsonVariant.
		
			
				
	
	
		
			33 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // ArduinoJson - arduinojson.org
 | |
| // Copyright Benoit Blanchon 2014-2018
 | |
| // MIT License
 | |
| 
 | |
| #include <ArduinoJson.h>
 | |
| #include <catch.hpp>
 | |
| 
 | |
| #define SHOULD_WORK(expression) REQUIRE(JsonError::Ok == expression);
 | |
| #define SHOULD_FAIL(expression) REQUIRE(JsonError::TooDeep == expression);
 | |
| 
 | |
| TEST_CASE("JsonDeserializer nestingLimit") {
 | |
|   DynamicJsonDocument doc;
 | |
| 
 | |
|   SECTION("limit = 0") {
 | |
|     SHOULD_WORK(deserializeJson(doc, "\"toto\"", 0));
 | |
|     SHOULD_WORK(deserializeJson(doc, "123", 0));
 | |
|     SHOULD_WORK(deserializeJson(doc, "true", 0));
 | |
|     SHOULD_FAIL(deserializeJson(doc, "[]", 0));
 | |
|     SHOULD_FAIL(deserializeJson(doc, "{}", 0));
 | |
|     SHOULD_FAIL(deserializeJson(doc, "[\"toto\"]", 0));
 | |
|     SHOULD_FAIL(deserializeJson(doc, "{\"toto\":1}", 0));
 | |
|   }
 | |
| 
 | |
|   SECTION("limit = 1") {
 | |
|     SHOULD_WORK(deserializeJson(doc, "[\"toto\"]", 1));
 | |
|     SHOULD_WORK(deserializeJson(doc, "{\"toto\":1}", 1));
 | |
|     SHOULD_FAIL(deserializeJson(doc, "{\"toto\":{}}", 1));
 | |
|     SHOULD_FAIL(deserializeJson(doc, "{\"toto\":[]}", 1));
 | |
|     SHOULD_FAIL(deserializeJson(doc, "[[\"toto\"]]", 1));
 | |
|     SHOULD_FAIL(deserializeJson(doc, "[{\"toto\":1}]", 1));
 | |
|   }
 | |
| }
 |