diff --git a/tests/ArduinoJsonParserTests.vcxproj b/tests/ArduinoJsonParserTests.vcxproj index fd3eb96c..637e48a8 100644 --- a/tests/ArduinoJsonParserTests.vcxproj +++ b/tests/ArduinoJsonParserTests.vcxproj @@ -1,103 +1,104 @@ - - - - - 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) - - - - - - - - - - - - - - - - - - - + + + + + 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 index 57105026..1d492eb6 100644 --- a/tests/ArduinoJsonParserTests.vcxproj.filters +++ b/tests/ArduinoJsonParserTests.vcxproj.filters @@ -1,51 +1,54 @@ - - - - - {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 - - + + + + + {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 + + + Source Files + + \ No newline at end of file diff --git a/tests/TestArrayExample.cpp b/tests/TestArrayExample.cpp new file mode 100644 index 00000000..3fc7abb7 --- /dev/null +++ b/tests/TestArrayExample.cpp @@ -0,0 +1,50 @@ +#include "CppUnitTest.h" +#include "JsonParser.h" + +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +namespace ArduinoJsonParserTests +{ + TEST_CLASS(TestArrayExample) + { + char json[128]; + JsonParser<32> parser; + JsonArray array; + + public: + + TEST_METHOD_INITIALIZE(Initialize) + { + strcpy(json, "[[1.2,3.4],[5.6,7.8]]"); + array = parser.parseArray(json); + } + + TEST_METHOD(Array_Success_ReturnsTrue) + { + Assert::IsTrue(array.success()); + } + + TEST_METHOD(Array_GetLength_Returns2) + { + Assert::AreEqual(2, array.getLength()); + } + + TEST_METHOD(Array_GetArray0_ReturnsInnerArray0) + { + JsonArray innerArray = array.getArray(0); + + Assert::AreEqual(2, innerArray.getLength()); + Assert::AreEqual(1.2, innerArray.getDouble(0)); + Assert::AreEqual(3.4, innerArray.getDouble(1)); + } + + TEST_METHOD(Array_GetArray1_ReturnsInnerArray1) + { + JsonArray innerArray = array.getArray(1); + + Assert::AreEqual(2, innerArray.getLength()); + Assert::AreEqual(5.6, innerArray.getDouble(0)); + Assert::AreEqual(7.8, innerArray.getDouble(1)); + } + }; +} \ No newline at end of file