mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Fixed JsonArrayIterator unit test
This commit is contained in:
		| @@ -16,43 +16,34 @@ namespace ArduinoJson | ||||
|  | ||||
|         class JsonArrayIterator | ||||
|         { | ||||
|             friend class JsonArray; | ||||
|  | ||||
|         public: | ||||
|  | ||||
|             JsonArrayIterator operator++() | ||||
|             { | ||||
|                 JsonArrayIterator prev = *this; | ||||
|                 token = token.nextSibling(); | ||||
|                 return prev; | ||||
|             } | ||||
|  | ||||
|             JsonValue operator*() | ||||
|             { | ||||
|                 return JsonValue(json, token); | ||||
|             } | ||||
|  | ||||
|             bool operator !=(const JsonArrayIterator& other) | ||||
|             { | ||||
|                 return token != other.token || json != other.json; | ||||
|             } | ||||
|  | ||||
|         private: | ||||
|  | ||||
|             char* json; | ||||
|             Internal::JsonToken token; | ||||
|  | ||||
|             JsonArrayIterator() | ||||
|                 : json(0), token(0) | ||||
|             { | ||||
|  | ||||
|             } | ||||
|  | ||||
|             JsonArrayIterator(char* json, Internal::JsonToken& token) | ||||
|                 : json(json), token(token) | ||||
|             { | ||||
|  | ||||
|             } | ||||
|  | ||||
|             const JsonArrayIterator& operator++() | ||||
|             { | ||||
|                 token = token.nextSibling(); | ||||
|                 return *this; | ||||
|             } | ||||
|  | ||||
|             JsonValue operator*() const | ||||
|             { | ||||
|                 return JsonValue(json, token); | ||||
|             } | ||||
|  | ||||
|             bool operator !=(const JsonArrayIterator& other) | ||||
|             { | ||||
|                 return token != other.token; | ||||
|             } | ||||
|  | ||||
|         private: | ||||
|  | ||||
|             char* json; | ||||
|             Internal::JsonToken token; | ||||
|         }; | ||||
|     } | ||||
| } | ||||
| @@ -14,16 +14,16 @@ namespace JsonParserTests | ||||
| 		TEST_METHOD(ThreeIntegers) | ||||
| 		{ | ||||
|             char json [] = "[1,2,3]"; | ||||
|             long expected [] = { 1, 2, 3 }; | ||||
|             JsonParser<4> parser; | ||||
|  | ||||
|             JsonArray a = parser.parse(json); | ||||
|              | ||||
|             long expected = 1; | ||||
|  | ||||
|             for (auto i : a) | ||||
|             int index = 0; | ||||
|  | ||||
|             for (long i : a) | ||||
|             { | ||||
|                 Assert::AreEqual(expected, (long)*i); | ||||
|                 expected++; | ||||
|                 Assert::AreEqual(expected[index++], i); | ||||
|             } | ||||
| 		} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user