mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-18 21:12:25 +02:00
Extracted a class to test strings
This commit is contained in:
@ -20,12 +20,6 @@ namespace ArduinoJsonParserTests
|
||||
|
||||
public:
|
||||
|
||||
TEST_METHOD(EmptyString)
|
||||
{
|
||||
whenInputIs("");
|
||||
parseMustFail();
|
||||
}
|
||||
|
||||
TEST_METHOD(TooFewClosingBrackets)
|
||||
{
|
||||
whenInputIs("[[]");
|
||||
|
@ -23,12 +23,6 @@ namespace ArduinoJsonParserTests
|
||||
|
||||
public:
|
||||
|
||||
TEST_METHOD(EmptyString)
|
||||
{
|
||||
whenInputIs("");
|
||||
parseMustFail();
|
||||
}
|
||||
|
||||
TEST_METHOD(EmptyHashTable)
|
||||
{
|
||||
whenInputIs("{}");
|
||||
|
@ -90,6 +90,7 @@
|
||||
<ClCompile Include="JsonArrayIteratorTests.cpp" />
|
||||
<ClCompile Include="JsonObjectTests.cpp" />
|
||||
<ClCompile Include="GbathreeBug.cpp" />
|
||||
<ClCompile Include="JsonStringTests.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JsonParser\JsonParser.vcxproj">
|
||||
|
@ -15,9 +15,6 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="JsonArrayTests.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GbathreeBug.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -30,5 +27,11 @@
|
||||
<ClCompile Include="JsonObjectIteratorTests.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="JsonArrayTests.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="JsonStringTests.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
53
JsonParserTests/JsonStringTests.cpp
Normal file
53
JsonParserTests/JsonStringTests.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Arduino JSON library
|
||||
* Benoit Blanchon 2014 - MIT License
|
||||
*/
|
||||
|
||||
#include "CppUnitTest.h"
|
||||
#include "JsonParser.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
using namespace ArduinoJson::Parser;
|
||||
|
||||
namespace ArduinoJsonParserTests
|
||||
{
|
||||
TEST_CLASS(JsonStringTests)
|
||||
{
|
||||
const char* actual;
|
||||
char json[256];
|
||||
JsonParser<32> parser;
|
||||
|
||||
public:
|
||||
|
||||
TEST_METHOD(EmptyString)
|
||||
{
|
||||
whenInputIs("");
|
||||
outputMustBe(0);
|
||||
}
|
||||
|
||||
TEST_METHOD(JustOneQuote)
|
||||
{
|
||||
whenInputIs("\"");
|
||||
outputMustBe(0);
|
||||
}
|
||||
|
||||
TEST_METHOD(EscapedQuote)
|
||||
{
|
||||
whenInputIs("\\\"");
|
||||
outputMustBe("\"");
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void whenInputIs(const char* input)
|
||||
{
|
||||
strcpy(json, input);
|
||||
actual = parser.parse(json);
|
||||
}
|
||||
|
||||
void outputMustBe(const char* expected)
|
||||
{
|
||||
Assert::AreEqual(expected, actual);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user