ソースを参照

Simplified JsonArray tests

Benoit Blanchon 11 年 前
コミット
6771603a05
1 ファイル変更27 行追加39 行削除
  1. 27 39
      JsonGeneratorTests/JsonArrayTests.cpp

+ 27 - 39
JsonGeneratorTests/JsonArrayTests.cpp

@@ -14,7 +14,7 @@ namespace JsonGeneratorTests
 {		
     TEST_CLASS(JsonArrayTests)
     {
-        JsonArray<2> arr;
+        JsonArray<2> array;
         char buffer[256];
 
     public:
@@ -26,98 +26,98 @@ namespace JsonGeneratorTests
 
         TEST_METHOD(Null)
         {
-            add((char*)0);
+            array.add((char*) 0);
 
             outputMustBe("[null]");
         }
 
         TEST_METHOD(OneString)
         {
-            add("hello");
+            array.add("hello");
 
             outputMustBe("[\"hello\"]");
         }
 
         TEST_METHOD(TwoStrings)
         {
-            add("hello");
-            add("world");
+            array.add("hello");
+            array.add("world");
 
             outputMustBe("[\"hello\",\"world\"]");
         }
 
         TEST_METHOD(OneStringOverCapacity)
         {
-            add("hello");
-            add("world");
-            add("lost");
+            array.add("hello");
+            array.add("world");
+            array.add("lost");
 
             outputMustBe("[\"hello\",\"world\"]");
         }
 
         TEST_METHOD(OneDoubleDefaultDigits)
         {
-            add(3.14159265358979323846);
+            array.add(3.14159265358979323846);
             outputMustBe("[3.14]");
         }
 
         TEST_METHOD(OneDoubleFourDigits)
         {
-            add<4>(3.14159265358979323846);
+            array.add<4>(3.14159265358979323846);
             outputMustBe("[3.1416]");
         }
 
         TEST_METHOD(OneInteger)
         {
-            add(1);
+            array.add(1);
 
             outputMustBe("[1]");
         }
 
         TEST_METHOD(TwoIntegers)
         {
-            add(1);
-            add(2);
+            array.add(1);
+            array.add(2);
 
             outputMustBe("[1,2]");
         }
 
         TEST_METHOD(OneIntegerOverCapacity)
         {
-            add(1);
-            add(2);
-            add(3);
+            array.add(1);
+            array.add(2);
+            array.add(3);
 
             outputMustBe("[1,2]");
         }
 
         TEST_METHOD(OneTrue)
         {
-            add(true);
+            array.add(true);
 
             outputMustBe("[true]");
         }
 
         TEST_METHOD(OneFalse)
         {
-            add(false);
+            array.add(false);
 
             outputMustBe("[false]");
         }
 
         TEST_METHOD(TwoBooleans)
         {
-            add(false);
-            add(true);
+            array.add(false);
+            array.add(true);
 
             outputMustBe("[false,true]");
         }
 
         TEST_METHOD(OneBooleanOverCapacity)
         {
-            add(false);
-            add(true);
-            add(false);
+            array.add(false);
+            array.add(true);
+            array.add(false);
 
             outputMustBe("[false,true]");
         }
@@ -126,7 +126,7 @@ namespace JsonGeneratorTests
         {
             JsonArray<1> nestedArray;
             
-            arr.add(nestedArray);
+            array.add(nestedArray);
 
             outputMustBe("[[]]");
         }
@@ -135,7 +135,7 @@ namespace JsonGeneratorTests
         {
             JsonObject<1> nestedObject;
 
-            arr.add(nestedObject);
+            array.add(nestedObject);
 
             outputMustBe("[{}]");
         }
@@ -145,28 +145,16 @@ namespace JsonGeneratorTests
             JsonArray<1> nestedArray;
             nestedArray.add(1);
 
-            arr.add(nestedArray);
+            array.add(nestedArray);
 
             outputMustBe("[[1]]");
         }
 
     private:
 
-        template<typename T>
-        void add(T value)
-        {
-            arr.add(value);
-        }
-
-        template<int DIGITS>
-        void add(double value)
-        {
-            arr.add<DIGITS>(value);
-        }
-
         void outputMustBe(const char* expected)
         {      
-            size_t n = arr.printTo(buffer, sizeof(buffer));
+            size_t n = array.printTo(buffer, sizeof(buffer));
             Assert::AreEqual(expected, buffer);
             Assert::AreEqual(strlen(expected), n);
         }