Просмотр исходного кода

Generator: added a test of a full array

Benoît Blanchon 11 лет назад
Родитель
Сommit
aa8cff7101
2 измененных файлов с 11 добавлено и 2 удалено
  1. 1 1
      JsonGeneratorTests/JsonArray.h
  2. 10 1
      JsonGeneratorTests/JsonArrayTests.cpp

+ 1 - 1
JsonGeneratorTests/JsonArray.h

@@ -16,7 +16,7 @@ public:
     
     void add(const char* data)
     {
-        if (itemCount <= N)
+        if (itemCount < N)
             items[itemCount++] = data;
     }
 

+ 10 - 1
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];