From df25a21050fc6070ff29d14066f3b342dd26c060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Blanchon?= Date: Tue, 24 Jun 2014 13:36:40 +0200 Subject: [PATCH] Generator: added a test of an array with 2 strings --- JsonGeneratorTests/JsonArray.h | 5 ++++- JsonGeneratorTests/JsonArrayTests.cpp | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/JsonGeneratorTests/JsonArray.h b/JsonGeneratorTests/JsonArray.h index 1202edc2..72faf572 100644 --- a/JsonGeneratorTests/JsonArray.h +++ b/JsonGeneratorTests/JsonArray.h @@ -28,8 +28,11 @@ public: for (int i = 0; i < itemCount; i++) { + if (i>0) + append(",", buffer, bufferSize); + append("'", buffer, bufferSize); - append(items[i], buffer, bufferSize); + append(items[i], buffer, bufferSize); append("'", buffer, bufferSize); } diff --git a/JsonGeneratorTests/JsonArrayTests.cpp b/JsonGeneratorTests/JsonArrayTests.cpp index ed7e8ec1..d372021e 100644 --- a/JsonGeneratorTests/JsonArrayTests.cpp +++ b/JsonGeneratorTests/JsonArrayTests.cpp @@ -7,7 +7,7 @@ namespace JsonGeneratorTests { TEST_CLASS(JsonArrayTests) { - JsonArray<32> arr; + JsonArray<3> arr; public: @@ -23,6 +23,14 @@ namespace JsonGeneratorTests AssertJsonIs("['hello']"); } + TEST_METHOD(TwoStrings) + { + arr.add("hello"); + arr.add("world"); + + AssertJsonIs("['hello','world']"); + } + void AssertJsonIs(const char* expected) { char buffer[256];