forked from bblanchon/ArduinoJson
Added a test class for StringBuilder
This commit is contained in:
@ -86,6 +86,7 @@
|
||||
<ClCompile Include="JsonArrayTests.cpp" />
|
||||
<ClCompile Include="JsonObjectBase.cpp" />
|
||||
<ClCompile Include="StringBuilder.cpp" />
|
||||
<ClCompile Include="StringBuilderTests.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="JsonArray.h" />
|
||||
|
@ -27,6 +27,9 @@
|
||||
<ClCompile Include="JsonObjectBase.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StringBuilderTests.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="JsonArray.h">
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Arduino JSON library
|
||||
* Benoit Blanchon 2014 - MIT License
|
||||
*/
|
||||
|
||||
#include "StringBuilder.h"
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
StringBuilder(char* buf, size_t size)
|
||||
: buffer(buf), capacity(size), length(0)
|
||||
{
|
||||
buffer[0] = 0;
|
||||
}
|
||||
|
||||
void append(const char* s);
|
||||
|
32
JsonGeneratorTests/StringBuilderTests.cpp
Normal file
32
JsonGeneratorTests/StringBuilderTests.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "CppUnitTest.h"
|
||||
#include "StringBuilder.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace JsonGeneratorTests
|
||||
{
|
||||
TEST_CLASS(StringBuilderTests)
|
||||
{
|
||||
char buffer[16];
|
||||
StringBuilder* sb;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
TEST_METHOD_INITIALIZE(Initialize)
|
||||
{
|
||||
sb = new StringBuilder(buffer, sizeof(buffer));
|
||||
}
|
||||
|
||||
TEST_METHOD(InitialState)
|
||||
{
|
||||
assertResultIs("");
|
||||
}
|
||||
|
||||
|
||||
void assertResultIs(const char* expected)
|
||||
{
|
||||
Assert::AreEqual(expected, buffer);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user