mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Renamed ARDUINO_JSON_NO_DEPRECATED_WARNING into ARDUINO_JSON_NO_DEPRECATION_WARNING
This commit is contained in:
		| @@ -97,6 +97,6 @@ namespace ArduinoJson | ||||
|         }; | ||||
|  | ||||
|         // Obsolete: Use JsonObject instead | ||||
|         typedef JsonObject JsonHashTable; | ||||
|         DEPRECATED typedef JsonObject JsonHashTable; | ||||
|     } | ||||
| } | ||||
| @@ -7,7 +7,7 @@ | ||||
|  | ||||
| #include "JsonToken.h" | ||||
|  | ||||
| #ifndef ARDUINO_JSON_NO_DEPRECATED_WARNING | ||||
| #ifndef ARDUINO_JSON_NO_DEPRECATION_WARNING | ||||
| #ifdef __GNUC__ | ||||
| #define DEPRECATED __attribute__((deprecated)) | ||||
| #elif defined(_MSC_VER) | ||||
|   | ||||
| @@ -3,8 +3,6 @@ | ||||
| * Benoit Blanchon 2014 - MIT License | ||||
| */ | ||||
|  | ||||
| #define ARDUINO_JSON_NO_DEPRECATED_WARNING | ||||
|  | ||||
| #include "CppUnitTest.h" | ||||
| #include "JsonParser.h" | ||||
| #include <string> | ||||
|   | ||||
| @@ -1,15 +1,19 @@ | ||||
| /* | ||||
| * Arduino JSON library | ||||
| * Benoit Blanchon 2014 - MIT License | ||||
| */ | ||||
|  | ||||
| #include "CppUnitTest.h" | ||||
| #include "JsonParser.h" | ||||
|  | ||||
| using namespace Microsoft::VisualStudio::CppUnitTestFramework; | ||||
| using namespace ArduinoJson::Parser; | ||||
|  | ||||
|  | ||||
| namespace JsonParserTests | ||||
| { | ||||
| 	TEST_CLASS(JsonArrayIteratorTests) | ||||
| 	{ | ||||
| 	public: | ||||
|     TEST_CLASS(JsonArrayIteratorTests) | ||||
|     { | ||||
|     public: | ||||
|  | ||||
|         TEST_METHOD(EmptyJson) | ||||
|         { | ||||
| @@ -27,11 +31,11 @@ namespace JsonParserTests | ||||
|  | ||||
|             Assert::AreEqual(0, loopCount); | ||||
|         } | ||||
| 		 | ||||
| 		TEST_METHOD(ThreeIntegers) | ||||
| 		{ | ||||
|  | ||||
|         TEST_METHOD(ThreeIntegers) | ||||
|         { | ||||
|             char json [] = "[1,2,3]"; | ||||
|             long expected [] = { 1, 2, 3 }; | ||||
|             long expected [] = {1, 2, 3}; | ||||
|             JsonParser<4> parser; | ||||
|  | ||||
|             JsonArray a = parser.parse(json); | ||||
| @@ -42,12 +46,12 @@ namespace JsonParserTests | ||||
|             { | ||||
|                 Assert::AreEqual(expected[index++], i); | ||||
|             } | ||||
| 		} | ||||
|         } | ||||
|  | ||||
|         TEST_METHOD(ThreeStrings) | ||||
|         { | ||||
|             char json[] = "[\"1\",\"2\",\"3\"]"; | ||||
|             char* expected[] = { "1", "2", "3" }; | ||||
|             char* expected[] = {"1", "2", "3"}; | ||||
|             JsonParser<4> parser; | ||||
|  | ||||
|             JsonArray a = parser.parse(json); | ||||
| @@ -59,5 +63,5 @@ namespace JsonParserTests | ||||
|                 Assert::AreEqual(expected[index++], i); | ||||
|             } | ||||
|         } | ||||
| 	}; | ||||
|     }; | ||||
| } | ||||
| @@ -3,8 +3,6 @@ | ||||
| * Benoit Blanchon 2014 - MIT License | ||||
| */ | ||||
|  | ||||
| #define ARDUINO_JSON_NO_DEPRECATED_WARNING | ||||
|  | ||||
| #include "CppUnitTest.h" | ||||
| #include "JsonParser.h" | ||||
|  | ||||
|   | ||||
| @@ -1,10 +1,14 @@ | ||||
| /* | ||||
| * Arduino JSON library | ||||
| * Benoit Blanchon 2014 - MIT License | ||||
| */ | ||||
|  | ||||
| #include "CppUnitTest.h" | ||||
| #include "JsonParser.h" | ||||
|  | ||||
| using namespace Microsoft::VisualStudio::CppUnitTestFramework; | ||||
| using namespace ArduinoJson::Parser; | ||||
|  | ||||
|  | ||||
| namespace JsonParserTests | ||||
| { | ||||
|     TEST_CLASS(JsonObjectIteratorTests) | ||||
| @@ -16,7 +20,7 @@ namespace JsonParserTests | ||||
|             char json [] = "{}"; | ||||
|             JsonParser<1> parser; | ||||
|  | ||||
|             JsonHashTable a = parser.parse(json);            | ||||
|             JsonHashTable a = parser.parse(json); | ||||
|  | ||||
|             int loopCount = 0; | ||||
|  | ||||
| @@ -48,8 +52,8 @@ namespace JsonParserTests | ||||
|         TEST_METHOD(ThreeStrings) | ||||
|         { | ||||
|             char json[] = "{\"key1\":\"value1\",\"key2\":\"value2\",\"key3\":\"value3\"}"; | ||||
|             char* expectedKeys[] = { "key1", "key2", "key3" }; | ||||
|             char* expectedValues[] = { "value1", "value2", "value3" }; | ||||
|             char* expectedKeys[] = {"key1", "key2", "key3"}; | ||||
|             char* expectedValues[] = {"value1", "value2", "value3"}; | ||||
|             JsonParser<7> parser; | ||||
|  | ||||
|             JsonHashTable a = parser.parse(json); | ||||
| @@ -63,6 +67,5 @@ namespace JsonParserTests | ||||
|                 index++; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|     }; | ||||
| } | ||||
| @@ -1,42 +1,40 @@ | ||||
| /* | ||||
| * Arduino JSON library | ||||
| * Benoit Blanchon 2014 - MIT License | ||||
| */ | ||||
| */ | ||||
|  | ||||
| #include "CppUnitTest.h" | ||||
| #include "JsonParser.h" | ||||
| #include <string> | ||||
|  | ||||
| using namespace std; | ||||
| using namespace Microsoft::VisualStudio::CppUnitTestFramework; | ||||
| using namespace ArduinoJson::Parser; | ||||
|  | ||||
| namespace ArduinoJsonParserTests | ||||
| { | ||||
|     TEST_CLASS(JsonHashTableTests) | ||||
|     { | ||||
|         JsonHashTable hashTable; | ||||
|         JsonArray nestedArray; | ||||
|         char json[256]; | ||||
|         jsmntok_t tokens[32]; | ||||
|         JsonParserBase parser = JsonParserBase(tokens, 32); | ||||
|  | ||||
|     public: | ||||
|  | ||||
| #define ARDUINO_JSON_NO_DEPRECATED_WARNING | ||||
|  | ||||
| #include "CppUnitTest.h" | ||||
| #include "JsonParser.h" | ||||
| #include <string> | ||||
|  | ||||
| using namespace std; | ||||
| using namespace Microsoft::VisualStudio::CppUnitTestFramework; | ||||
| using namespace ArduinoJson::Parser; | ||||
|  | ||||
| namespace ArduinoJsonParserTests | ||||
| {		 | ||||
|     TEST_CLASS(JsonHashTableTests) | ||||
| 	{ | ||||
| 		JsonHashTable hashTable; | ||||
|         JsonArray nestedArray; | ||||
| 		char json[256]; | ||||
|         jsmntok_t tokens[32]; | ||||
|         JsonParserBase parser = JsonParserBase(tokens, 32); | ||||
|  | ||||
| 	public: | ||||
|  | ||||
|         TEST_METHOD(EmptyString) | ||||
|         { | ||||
|             whenInputIs(""); | ||||
|             parseMustFail(); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         TEST_METHOD(EmptyHashTable) | ||||
|         { | ||||
|             whenInputIs("{}"); | ||||
|             parseMustSucceed(); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         TEST_METHOD(NotEnoughTokens) | ||||
|         { | ||||
|             setTokenCountTo(2); | ||||
| @@ -45,8 +43,8 @@ namespace ArduinoJsonParserTests | ||||
|  | ||||
|             parseMustFail(); | ||||
|             itemMustNotExist("key"); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         TEST_METHOD(TwoIntegers) | ||||
|         { | ||||
|             setTokenCountTo(5); | ||||
| @@ -57,8 +55,8 @@ namespace ArduinoJsonParserTests | ||||
|             itemMustBe("key1", 1L); | ||||
|             itemMustBe("key2", 2L); | ||||
|             itemMustNotExist("key3"); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         TEST_METHOD(TwoBooleans) | ||||
|         { | ||||
|             setTokenCountTo(5); | ||||
| @@ -69,8 +67,8 @@ namespace ArduinoJsonParserTests | ||||
|             itemMustBe("key1", true); | ||||
|             itemMustBe("key2", false); | ||||
|             itemMustNotExist("key3"); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         TEST_METHOD(TwoStrings) | ||||
|         { | ||||
|             setTokenCountTo(5); | ||||
| @@ -81,8 +79,8 @@ namespace ArduinoJsonParserTests | ||||
|             itemMustBe("key1", "hello"); | ||||
|             itemMustBe("key2", "world"); | ||||
|             itemMustNotExist("key3"); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         TEST_METHOD(TwoNestedArrays) | ||||
|         { | ||||
|             setTokenCountTo(9); | ||||
| @@ -103,15 +101,15 @@ namespace ArduinoJsonParserTests | ||||
|             arrayItemMustBe(2, 0L); | ||||
|  | ||||
|             itemMustNotExist("key3"); | ||||
|         } | ||||
|  | ||||
|     private: | ||||
|  | ||||
|         void setTokenCountTo(int n) | ||||
|         { | ||||
|             parser = JsonParserBase(tokens, n); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|     private: | ||||
|  | ||||
|         void setTokenCountTo(int n) | ||||
|         { | ||||
|             parser = JsonParserBase(tokens, n); | ||||
|         } | ||||
|  | ||||
|         void whenInputIs(const char* input) | ||||
|         { | ||||
|             strcpy(json, input); | ||||
| @@ -121,53 +119,53 @@ namespace ArduinoJsonParserTests | ||||
|         void parseMustFail() | ||||
|         { | ||||
|             Assert::IsFalse(hashTable.success()); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         void parseMustSucceed() | ||||
|         { | ||||
|             Assert::IsTrue(hashTable.success()); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         void itemMustBe(const char* key, long expected) | ||||
|         { | ||||
|             Assert::AreEqual(expected, hashTable.getLong(key)); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         void itemMustBe(const char* key, bool expected) | ||||
|         { | ||||
|             Assert::AreEqual(expected, hashTable.getBool(key)); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         void itemMustBe(const char* key, const char* expected) | ||||
|         { | ||||
|             Assert::AreEqual(expected, hashTable.getString(key)); | ||||
|         } | ||||
|  | ||||
|         void itemMustNotExist(const char* key) | ||||
|         { | ||||
|             Assert::IsFalse(hashTable.containsKey(key)); | ||||
|             Assert::IsFalse(hashTable.getHashTable(key).success()); | ||||
|             Assert::IsFalse(hashTable.getArray(key).success()); | ||||
|             Assert::IsFalse(hashTable.getBool(key)); | ||||
|             Assert::AreEqual(0.0, hashTable.getDouble(key)); | ||||
|             Assert::AreEqual(0L,  hashTable.getLong(key)); | ||||
|             Assert::IsNull(hashTable.getString(key)); | ||||
|         } | ||||
|  | ||||
|         void itemMustBeAnArray(const char* key) | ||||
|         { | ||||
|             nestedArray = hashTable.getArray(key); | ||||
|             Assert::IsTrue(nestedArray.success()); | ||||
|         } | ||||
|  | ||||
|         void arrayLengthMustBe(int expected) | ||||
|         { | ||||
|             Assert::AreEqual(expected, nestedArray.getLength()); | ||||
|         } | ||||
|  | ||||
|         void arrayItemMustBe(int index, long expected) | ||||
|         { | ||||
|             Assert::AreEqual(expected, nestedArray.getLong(index)); | ||||
|         } | ||||
| 	}; | ||||
|         } | ||||
|  | ||||
|         void itemMustNotExist(const char* key) | ||||
|         { | ||||
|             Assert::IsFalse(hashTable.containsKey(key)); | ||||
|             Assert::IsFalse(hashTable.getHashTable(key).success()); | ||||
|             Assert::IsFalse(hashTable.getArray(key).success()); | ||||
|             Assert::IsFalse(hashTable.getBool(key)); | ||||
|             Assert::AreEqual(0.0, hashTable.getDouble(key)); | ||||
|             Assert::AreEqual(0L, hashTable.getLong(key)); | ||||
|             Assert::IsNull(hashTable.getString(key)); | ||||
|         } | ||||
|  | ||||
|         void itemMustBeAnArray(const char* key) | ||||
|         { | ||||
|             nestedArray = hashTable.getArray(key); | ||||
|             Assert::IsTrue(nestedArray.success()); | ||||
|         } | ||||
|  | ||||
|         void arrayLengthMustBe(int expected) | ||||
|         { | ||||
|             Assert::AreEqual(expected, nestedArray.getLength()); | ||||
|         } | ||||
|  | ||||
|         void arrayItemMustBe(int index, long expected) | ||||
|         { | ||||
|             Assert::AreEqual(expected, nestedArray.getLong(index)); | ||||
|         } | ||||
|     }; | ||||
| } | ||||
| @@ -56,7 +56,7 @@ | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <PreprocessorDefinitions>ARDUINO_JSON_NO_DEPRECATION_WARNING;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <UseFullPaths>true</UseFullPaths> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user