Generator: added a test of an array with 2 strings

This commit is contained in:
Benoît Blanchon
2014-06-24 13:36:40 +02:00
parent f18f554c2f
commit df25a21050
2 changed files with 13 additions and 2 deletions

View File

@ -28,8 +28,11 @@ public:
for (int i = 0; i < itemCount; i++) for (int i = 0; i < itemCount; i++)
{ {
if (i>0)
append(",", buffer, bufferSize);
append("'", buffer, bufferSize); append("'", buffer, bufferSize);
append(items[i], buffer, bufferSize); append(items[i], buffer, bufferSize);
append("'", buffer, bufferSize); append("'", buffer, bufferSize);
} }

View File

@ -7,7 +7,7 @@ namespace JsonGeneratorTests
{ {
TEST_CLASS(JsonArrayTests) TEST_CLASS(JsonArrayTests)
{ {
JsonArray<32> arr; JsonArray<3> arr;
public: public:
@ -23,6 +23,14 @@ namespace JsonGeneratorTests
AssertJsonIs("['hello']"); AssertJsonIs("['hello']");
} }
TEST_METHOD(TwoStrings)
{
arr.add("hello");
arr.add("world");
AssertJsonIs("['hello','world']");
}
void AssertJsonIs(const char* expected) void AssertJsonIs(const char* expected)
{ {
char buffer[256]; char buffer[256];