Fixed the failing tests

This commit is contained in:
Benoît Blanchon
2014-06-27 13:24:10 +02:00
parent 568b8988d8
commit dd8baea373

View File

@ -16,86 +16,86 @@ namespace JsonGeneratorTests
TEST_METHOD(AddNull) TEST_METHOD(AddNull)
{ {
add((char*)0); addValue((char*)0);
jsonIs("[null]"); jsonIs("[null]");
} }
TEST_METHOD(AddOneString) TEST_METHOD(AddOneString)
{ {
add("hello"); addValue("hello");
jsonIs("[\"hello\"]"); jsonIs("[\"hello\"]");
} }
TEST_METHOD(AddTwoStrings) TEST_METHOD(AddTwoStrings)
{ {
add("hello"); addValue("hello");
add("world"); addValue("world");
jsonIs("[\"hello\",\"world\"]"); jsonIs("[\"hello\",\"world\"]");
} }
TEST_METHOD(AddOneStringOverCapacity) TEST_METHOD(AddOneStringOverCapacity)
{ {
add("hello"); addValue("hello");
add("world"); addValue("world");
add("lost"); addValue("lost");
jsonIs("[\"hello\",\"world\"]"); jsonIs("[\"hello\",\"world\"]");
} }
TEST_METHOD(AddOneNumber) TEST_METHOD(AddOneNumber)
{ {
add(3.14); addValue(3.14);
jsonIs("[3.14]"); jsonIs("[3.14]");
} }
TEST_METHOD(AddTwoNumbers) TEST_METHOD(AddTwoNumbers)
{ {
add(3.14); addValue(3.14);
add(2.72); addValue(2.72);
jsonIs("[3.14,2.72]"); jsonIs("[3.14,2.72]");
} }
TEST_METHOD(AddOneNumberOverCapacity) TEST_METHOD(AddOneNumberOverCapacity)
{ {
add(3.14); addValue(3.14);
add(2.72); addValue(2.72);
add(1.41); addValue(1.41);
jsonIs("[3.14,2.72]"); jsonIs("[3.14,2.72]");
} }
TEST_METHOD(AddTrue) TEST_METHOD(AddTrue)
{ {
add(true); addValue(true);
jsonIs("[true]"); jsonIs("[true]");
} }
TEST_METHOD(AddFalse) TEST_METHOD(AddFalse)
{ {
add(false); addValue(false);
jsonIs("[false]"); jsonIs("[false]");
} }
TEST_METHOD(AddTwoBooleans) TEST_METHOD(AddTwoBooleans)
{ {
add(false); addValue(false);
add(true); addValue(true);
jsonIs("[false,true]"); jsonIs("[false,true]");
} }
TEST_METHOD(AddOneBooleanOverCapacity) TEST_METHOD(AddOneBooleanOverCapacity)
{ {
add(false); addValue(false);
add(true); addValue(true);
add(false); addValue(false);
jsonIs("[false,true]"); jsonIs("[false,true]");
} }
@ -104,7 +104,7 @@ namespace JsonGeneratorTests
{ {
JsonArray<1> nestedArray; JsonArray<1> nestedArray;
add(nestedArray); addNested(nestedArray);
jsonIs("[[]]"); jsonIs("[[]]");
} }
@ -114,7 +114,7 @@ namespace JsonGeneratorTests
JsonArray<1> nestedArray; JsonArray<1> nestedArray;
nestedArray.add(3.14); nestedArray.add(3.14);
add(nestedArray); addNested(nestedArray);
jsonIs("[[3.14]]"); jsonIs("[[3.14]]");
} }
@ -123,8 +123,13 @@ namespace JsonGeneratorTests
JsonArray<2> arr; JsonArray<2> arr;
void addNested(JsonObjectBase& value)
{
arr.add(value);
}
template<typename T> template<typename T>
void add(T value) void addValue(T value)
{ {
arr.add(value); arr.add(value);
} }