diff --git a/tests/ArduinoJsonParserTests.sln b/tests/ArduinoJsonParserTests.sln new file mode 100644 index 00000000..f796c4db --- /dev/null +++ b/tests/ArduinoJsonParserTests.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArduinoJsonParserTests", "ArduinoJsonParserTests.vcxproj", "{4DD596EF-0185-4AB4-A3C2-F20C496F7806}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4DD596EF-0185-4AB4-A3C2-F20C496F7806}.Debug|Win32.ActiveCfg = Debug|Win32 + {4DD596EF-0185-4AB4-A3C2-F20C496F7806}.Debug|Win32.Build.0 = Debug|Win32 + {4DD596EF-0185-4AB4-A3C2-F20C496F7806}.Release|Win32.ActiveCfg = Release|Win32 + {4DD596EF-0185-4AB4-A3C2-F20C496F7806}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tests/ArduinoJsonParserTests.vcxproj b/tests/ArduinoJsonParserTests.vcxproj new file mode 100644 index 00000000..fd3eb96c --- /dev/null +++ b/tests/ArduinoJsonParserTests.vcxproj @@ -0,0 +1,103 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {4DD596EF-0185-4AB4-A3C2-F20C496F7806} + Win32Proj + ArduinoJsonParserTests + + + + DynamicLibrary + true + v120 + Unicode + false + + + DynamicLibrary + false + v120 + true + Unicode + false + + + + + + + + + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);.. + + + true + $(VC_IncludePath);.. + + + + NotUsing + Level3 + Disabled + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/ArduinoJsonParserTests.vcxproj.filters b/tests/ArduinoJsonParserTests.vcxproj.filters new file mode 100644 index 00000000..57105026 --- /dev/null +++ b/tests/ArduinoJsonParserTests.vcxproj.filters @@ -0,0 +1,51 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/tests/TestHashTableExample.cpp b/tests/TestHashTableExample.cpp new file mode 100644 index 00000000..2eac9927 --- /dev/null +++ b/tests/TestHashTableExample.cpp @@ -0,0 +1,61 @@ +#include "CppUnitTest.h" +#include "JsonParser.h" +#include + +using namespace std; +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +namespace ArduinoJsonParserTests +{ + TEST_CLASS(TestHashTableExample) + { + char json[128]; + JsonParser<32> parser; + JsonHashTable hashTable; + + public: + + TEST_METHOD_INITIALIZE(Initialize) + { + strcpy(json, "{\"Name\":\"Blanchon\",\"Skills\":[\"C\",\"C++\",\"C#\"],\"Age\":32,\"Online\":true}"); + hashTable = parser.parseHashTable(json); + } + + TEST_METHOD(HashTable_Success_ReturnsTrue) + { + Assert::IsTrue(hashTable.success()); + } + + TEST_METHOD(HashTable_GetString_ReturnsExpectedValue) + { + string name = hashTable.getString("Name"); + Assert::AreEqual(name, string("Blanchon")); + } + + TEST_METHOD(HashTable_GetArray_ReturnsExpectedValue) + { + JsonArray skills = hashTable.getArray("Skills"); + + string skill0 = skills.getString(0); + Assert::AreEqual(skill0, string("C")); + + string skill1 = skills.getString(1); + Assert::AreEqual(skill1, string("C++")); + + string skill2 = skills.getString(2); + Assert::AreEqual(skill2, string("C#")); + } + + TEST_METHOD(HashTable_GetLong_ReturnsExpectedValue) + { + int age = hashTable.getLong("Age"); + Assert::AreEqual(32, age); + } + + TEST_METHOD(HashTable_GetBool_ReturnsExpectedValue) + { + bool online = hashTable.getBool("Online"); + Assert::AreEqual(true, online); + } + }; +} \ No newline at end of file