replace json::from() with explicit Value() constructors
This commit is contained in:
30
test.cpp
30
test.cpp
@@ -49,15 +49,15 @@ int json_cpp_tests() {
|
||||
i.next();
|
||||
ASSERT_FALSE(i.valid(), "iterator has more values than expected");
|
||||
|
||||
json::Value e5(json::from(12.34));
|
||||
json::Value e5(json::Value(12.34));
|
||||
ASSERT_TRUE(e5.is_number(), "e5 is not a number after assignment");
|
||||
ASSERT_EQ(e5.as_real(), 12.34, "e5 has incorrect value after assignment");
|
||||
|
||||
json::Value e6(json::from(true));
|
||||
json::Value e6(json::Value(true));
|
||||
ASSERT_TRUE(e6.is_boolean(), "e6 is not a boolean after assignment");
|
||||
ASSERT_EQ(e6.as_boolean(), true, "e6 has incorrect value after assignment");
|
||||
|
||||
json::Value e7(json::from("foobar"));
|
||||
json::Value e7(json::Value("foobar"));
|
||||
ASSERT_TRUE(e7.is_string(), "e7 is not a string after assignment");
|
||||
ASSERT_EQ(e7.as_string(), "foobar", "e7 has incorrect value after assignment");
|
||||
|
||||
@@ -70,16 +70,16 @@ int json_cpp_tests() {
|
||||
json::Value e10(json::array());
|
||||
ASSERT_TRUE(e10.is_array(), "e10 is not an array after index assignment");
|
||||
|
||||
e10.set_at(0, json::from("foobar"));
|
||||
e10.set_at(0, json::Value("foobar"));
|
||||
ASSERT_EQ(e10.size(), 1, "e10 has incorrect number of elements after assignment");
|
||||
ASSERT_EQ(e10[0].as_string(), "foobar", "e10[0] has incorrect value after assignment");
|
||||
|
||||
e10.set_at(1, json::from("foobar"));
|
||||
e10.set_at(1, json::Value("foobar"));
|
||||
ASSERT_TRUE(e10.is_array(), "e10 is not an array after index assignment");
|
||||
ASSERT_EQ(e10.size(), 2, "e10 has incorrect number of elements after assignment");
|
||||
ASSERT_EQ(e10[1].as_string(), "foobar", "e10[0] has incorrect value after assignment");
|
||||
|
||||
e10.set_at(0, json::from("barfoo"));
|
||||
e10.set_at(0, json::Value("barfoo"));
|
||||
ASSERT_TRUE(e10.is_array(), "e10 is not an array after index assignment");
|
||||
ASSERT_EQ(e10.size(), 2, "e10 has incorrect number of elements after assignment");
|
||||
ASSERT_EQ(e10[0].as_string(), "barfoo", "e10[0] has incorrect value after assignment");
|
||||
@@ -88,7 +88,7 @@ int json_cpp_tests() {
|
||||
ASSERT_TRUE(e10.is_array(), "e10 is not an array after index assignment");
|
||||
ASSERT_EQ(e10.size(), 2, "e10 has incorrect number of elements after assignment");
|
||||
|
||||
e10.insert_at(1, json::from("new"));
|
||||
e10.insert_at(1, json::Value("new"));
|
||||
ASSERT_EQ(e10.size(), 3, "e10 has incorrect size after insert");
|
||||
ASSERT_EQ(e10[1].as_string(), "new", "e10[1] has incorrect value after insert");
|
||||
ASSERT_EQ(e10[2].as_string(), "foobar", "e10[2] has incorrect value after insert");
|
||||
@@ -103,16 +103,16 @@ int json_cpp_tests() {
|
||||
json::Value e11(json::object());
|
||||
ASSERT_TRUE(e11.is_object(), "e11 is not an object after property assignment");
|
||||
|
||||
e11.set_key("foo", json::from("test"));
|
||||
e11.set_key("foo", json::Value("test"));
|
||||
ASSERT_EQ(e11.size(), 1, "e11 has incorrect number of properties after assignment");
|
||||
ASSERT_EQ(e11["foo"].as_string(), "test", "e11.foo has incorrect value after assignment");
|
||||
|
||||
e11.set_key("foo", json::from("again"));
|
||||
e11.set_key("foo", json::Value("again"));
|
||||
ASSERT_TRUE(e11.is_object(), "e11 is not an object after property assignment");
|
||||
ASSERT_EQ(e11.size(), 1, "e11 has incorrect number of properties after assignment");
|
||||
ASSERT_EQ(e11["foo"].as_string(), "again", "e11.foo has incorrect value after assignment");
|
||||
|
||||
e11.set_key("bar", json::from("test"));
|
||||
e11.set_key("bar", json::Value("test"));
|
||||
ASSERT_TRUE(e11.is_object(), "e11 is not an object after property assignment");
|
||||
ASSERT_EQ(e11.size(), 2, "e11 has incorrect number of properties after assignment");
|
||||
ASSERT_EQ(e11["bar"].as_string(), "test", "e11.foo has incorrect value after assignment");
|
||||
@@ -121,8 +121,8 @@ int json_cpp_tests() {
|
||||
ASSERT_EQ(e11.size(), 0, "e11 has incorrect number of properties after clear");
|
||||
|
||||
json::Value e12(json::object());
|
||||
e12.set_key("foo", json::from("test"));
|
||||
e12.set_key("bar", json::from(3));
|
||||
e12.set_key("foo", json::Value("test"));
|
||||
e12.set_key("bar", json::Value(3));
|
||||
char* out_cstr = e12.save_string(0);
|
||||
std::string out(out_cstr);
|
||||
free(out_cstr);
|
||||
@@ -146,14 +146,14 @@ int json_cpp_tests() {
|
||||
ASSERT_TRUE(e14.is_object(), "e14 is not an object after construction");
|
||||
e14.set_key("foo", json::object());
|
||||
ASSERT_TRUE(e14["foo"].is_object(), "e14.foo is not an object after assignment");
|
||||
e14["foo"]["bar"] = json::from(42);
|
||||
e14["foo"]["bar"] = json::Value(42);
|
||||
ASSERT_EQ(e14["foo"]["bar"].as_integer(), 42, "e14.foo.bar has incorrect value after assignment");
|
||||
|
||||
json::Value e15(json::array());
|
||||
ASSERT_TRUE(e15.is_array(), "e15 is not an array after construction");
|
||||
e15.set_at(0, json::from(42));
|
||||
e15.set_at(0, json::Value(42));
|
||||
ASSERT_EQ(e15[0].as_integer(), 42, "e15[0] has incorrect value after assignment");
|
||||
e15[0] = json::from("foo");
|
||||
e15[0] = json::Value("foo");
|
||||
ASSERT_EQ(e15[0].as_string(), "foo", "e15[0] has incorrecy value after assignment");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user