From aa8cff7101f07ad5e699277dc760a2c63ca2d1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Blanchon?= Date: Tue, 24 Jun 2014 13:38:48 +0200 Subject: [PATCH] Generator: added a test of a full array --- JsonGeneratorTests/JsonArray.h | 2 +- JsonGeneratorTests/JsonArrayTests.cpp | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/JsonGeneratorTests/JsonArray.h b/JsonGeneratorTests/JsonArray.h index 72faf572..ef955861 100644 --- a/JsonGeneratorTests/JsonArray.h +++ b/JsonGeneratorTests/JsonArray.h @@ -16,7 +16,7 @@ public: void add(const char* data) { - if (itemCount <= N) + if (itemCount < N) items[itemCount++] = data; } diff --git a/JsonGeneratorTests/JsonArrayTests.cpp b/JsonGeneratorTests/JsonArrayTests.cpp index d372021e..d06d2e75 100644 --- a/JsonGeneratorTests/JsonArrayTests.cpp +++ b/JsonGeneratorTests/JsonArrayTests.cpp @@ -7,7 +7,7 @@ namespace JsonGeneratorTests { TEST_CLASS(JsonArrayTests) { - JsonArray<3> arr; + JsonArray<2> arr; public: @@ -31,6 +31,15 @@ namespace JsonGeneratorTests AssertJsonIs("['hello','world']"); } + TEST_METHOD(OverCapacity) + { + arr.add("hello"); + arr.add("world"); + arr.add("lost"); + + AssertJsonIs("['hello','world']"); + } + void AssertJsonIs(const char* expected) { char buffer[256];