mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	* Added DynamicJsonArray and StaticJsonArray * Added DynamicJsonObject and StaticJsonObject * Added DynamicJsonVariant and StaticJsonVariant * Added deserializeJson() * Removed JsonBuffer::parseArray(), parseObject() and parse() * Removed JsonBuffer::createArray() and createObject()
		
			
				
	
	
		
			37 lines
		
	
	
		
			783 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			783 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| // ArduinoJson - arduinojson.org
 | |
| // Copyright Benoit Blanchon 2014-2018
 | |
| // MIT License
 | |
| 
 | |
| #include <ArduinoJson.h>
 | |
| #include <catch.hpp>
 | |
| 
 | |
| template <typename TIterator>
 | |
| static void run_iterator_test() {
 | |
|   StaticJsonArray<JSON_ARRAY_SIZE(2)> array;
 | |
|   array.add(12);
 | |
|   array.add(34);
 | |
| 
 | |
|   TIterator it = array.begin();
 | |
|   TIterator end = array.end();
 | |
| 
 | |
|   REQUIRE(end != it);
 | |
|   REQUIRE(12 == it->template as<int>());
 | |
|   REQUIRE(12 == static_cast<int>(*it));
 | |
|   ++it;
 | |
|   REQUIRE(end != it);
 | |
|   REQUIRE(34 == it->template as<int>());
 | |
|   REQUIRE(34 == static_cast<int>(*it));
 | |
|   ++it;
 | |
|   REQUIRE(end == it);
 | |
| }
 | |
| 
 | |
| TEST_CASE("JsonArray::begin()/end()") {
 | |
|   SECTION("Mutable") {
 | |
|     run_iterator_test<JsonArray::iterator>();
 | |
|   }
 | |
| 
 | |
|   SECTION("Const") {
 | |
|     run_iterator_test<JsonArray::const_iterator>();
 | |
|   }
 | |
| }
 |