From c8c1add4abfb1061a0ff27eda8ed4b485d02ba7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Blanchon?= Date: Tue, 24 Jun 2014 13:19:23 +0200 Subject: [PATCH] Generator: added empty array test --- JsonGeneratorTests/.gitignore | 5 + JsonGeneratorTests/JsonArray.cpp | 14 +++ JsonGeneratorTests/JsonArray.h | 13 +++ JsonGeneratorTests/JsonArrayTests.cpp | 22 +++++ JsonGeneratorTests/JsonGeneratorTests.sln | 22 +++++ JsonGeneratorTests/JsonGeneratorTests.vcxproj | 94 +++++++++++++++++++ .../JsonGeneratorTests.vcxproj.filters | 30 ++++++ 7 files changed, 200 insertions(+) create mode 100644 JsonGeneratorTests/.gitignore create mode 100644 JsonGeneratorTests/JsonArray.cpp create mode 100644 JsonGeneratorTests/JsonArray.h create mode 100644 JsonGeneratorTests/JsonArrayTests.cpp create mode 100644 JsonGeneratorTests/JsonGeneratorTests.sln create mode 100644 JsonGeneratorTests/JsonGeneratorTests.vcxproj create mode 100644 JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters diff --git a/JsonGeneratorTests/.gitignore b/JsonGeneratorTests/.gitignore new file mode 100644 index 00000000..abbcaa0a --- /dev/null +++ b/JsonGeneratorTests/.gitignore @@ -0,0 +1,5 @@ +/*.sdf +/*.user +/*.suo +/Debug +/ipch diff --git a/JsonGeneratorTests/JsonArray.cpp b/JsonGeneratorTests/JsonArray.cpp new file mode 100644 index 00000000..510953c2 --- /dev/null +++ b/JsonGeneratorTests/JsonArray.cpp @@ -0,0 +1,14 @@ +/* +* Arduino JSON library +* Benoit Blanchon 2014 - MIT License +*/ + +#include + +#include "JsonArray.h" + +void JsonArray::writeTo(char* buffer, size_t bufferSize) +{ + strncpy(buffer, "[]", bufferSize); + +} \ No newline at end of file diff --git a/JsonGeneratorTests/JsonArray.h b/JsonGeneratorTests/JsonArray.h new file mode 100644 index 00000000..02104a4c --- /dev/null +++ b/JsonGeneratorTests/JsonArray.h @@ -0,0 +1,13 @@ +/* + * Arduino JSON library + * Benoit Blanchon 2014 - MIT License + */ + +#pragma once + +class JsonArray +{ +public: + void writeTo(char* buffer, size_t bufferSize); +}; + diff --git a/JsonGeneratorTests/JsonArrayTests.cpp b/JsonGeneratorTests/JsonArrayTests.cpp new file mode 100644 index 00000000..4ea84f71 --- /dev/null +++ b/JsonGeneratorTests/JsonArrayTests.cpp @@ -0,0 +1,22 @@ +#include "CppUnitTest.h" +#include "JsonArray.h" + +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +namespace JsonGeneratorTests +{ + TEST_CLASS(JsonArrayTests) + { + public: + + TEST_METHOD(EmptyArray) + { + JsonArray arr; + + char buffer[256]; + arr.writeTo(buffer, sizeof(buffer)); + + Assert::AreEqual("[]", buffer); + } + }; +} \ No newline at end of file diff --git a/JsonGeneratorTests/JsonGeneratorTests.sln b/JsonGeneratorTests/JsonGeneratorTests.sln new file mode 100644 index 00000000..3104cc9c --- /dev/null +++ b/JsonGeneratorTests/JsonGeneratorTests.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JsonGeneratorTests", "JsonGeneratorTests.vcxproj", "{B9545D97-E084-4A19-8E48-929157064360}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B9545D97-E084-4A19-8E48-929157064360}.Debug|Win32.ActiveCfg = Debug|Win32 + {B9545D97-E084-4A19-8E48-929157064360}.Debug|Win32.Build.0 = Debug|Win32 + {B9545D97-E084-4A19-8E48-929157064360}.Release|Win32.ActiveCfg = Release|Win32 + {B9545D97-E084-4A19-8E48-929157064360}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/JsonGeneratorTests/JsonGeneratorTests.vcxproj b/JsonGeneratorTests/JsonGeneratorTests.vcxproj new file mode 100644 index 00000000..845c27bc --- /dev/null +++ b/JsonGeneratorTests/JsonGeneratorTests.vcxproj @@ -0,0 +1,94 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {B9545D97-E084-4A19-8E48-929157064360} + Win32Proj + JsonGeneratorTests + + + + DynamicLibrary + true + v120 + Unicode + false + + + DynamicLibrary + false + v120 + true + Unicode + false + + + + + + + + + + + + + true + + + true + + + + NotUsing + Level3 + Disabled + $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + 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/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters b/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters new file mode 100644 index 00000000..ee0db9b8 --- /dev/null +++ b/JsonGeneratorTests/JsonGeneratorTests.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {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 + + + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file