mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Removed StaticJsonArray and DynamicJsonArray. Removed StaticJsonObject and DynamicJsonObject. Removed StaticJsonVariant and DynamicJsonVariant.
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // ArduinoJson - arduinojson.org
 | |
| // Copyright Benoit Blanchon 2014-2018
 | |
| // MIT License
 | |
| 
 | |
| #include <ArduinoJson/Memory/DynamicJsonBuffer.hpp>
 | |
| #include <catch.hpp>
 | |
| 
 | |
| using namespace ArduinoJson::Internals;
 | |
| 
 | |
| TEST_CASE("DynamicJsonBuffer::startString()") {
 | |
|   SECTION("WorksWhenBufferIsBigEnough") {
 | |
|     DynamicJsonBuffer jsonBuffer(6);
 | |
| 
 | |
|     DynamicJsonBuffer::String str = jsonBuffer.startString();
 | |
|     str.append('h');
 | |
|     str.append('e');
 | |
|     str.append('l');
 | |
|     str.append('l');
 | |
|     str.append('o');
 | |
| 
 | |
|     REQUIRE(std::string("hello") == str.c_str());
 | |
|   }
 | |
| 
 | |
|   SECTION("GrowsWhenBufferIsTooSmall") {
 | |
|     DynamicJsonBuffer jsonBuffer(5);
 | |
| 
 | |
|     DynamicJsonBuffer::String str = jsonBuffer.startString();
 | |
|     str.append('h');
 | |
|     str.append('e');
 | |
|     str.append('l');
 | |
|     str.append('l');
 | |
|     str.append('o');
 | |
| 
 | |
|     REQUIRE(std::string("hello") == str.c_str());
 | |
|   }
 | |
| 
 | |
|   SECTION("SizeIncreases") {
 | |
|     DynamicJsonBuffer jsonBuffer(5);
 | |
| 
 | |
|     DynamicJsonBuffer::String str = jsonBuffer.startString();
 | |
|     REQUIRE(0 == jsonBuffer.size());
 | |
| 
 | |
|     str.append('h');
 | |
|     REQUIRE(1 == jsonBuffer.size());
 | |
| 
 | |
|     str.c_str();
 | |
|     REQUIRE(2 == jsonBuffer.size());
 | |
|   }
 | |
| }
 |