Commit f688b2b1 authored by miloyip's avatar miloyip

Improve coverage of Pointer

parent 32295665
...@@ -873,7 +873,9 @@ TEST(Pointer, Erase) { ...@@ -873,7 +873,9 @@ TEST(Pointer, Erase) {
d.Parse(kJson); d.Parse(kJson);
EXPECT_FALSE(Pointer("").Erase(d)); EXPECT_FALSE(Pointer("").Erase(d));
EXPECT_FALSE(Pointer("/nonexist").Erase(d));
EXPECT_FALSE(Pointer("/foo/nonexist").Erase(d)); EXPECT_FALSE(Pointer("/foo/nonexist").Erase(d));
EXPECT_FALSE(Pointer("/foo/0/nonexist").Erase(d));
EXPECT_TRUE(Pointer("/foo/0").Erase(d)); EXPECT_TRUE(Pointer("/foo/0").Erase(d));
EXPECT_EQ(1u, d["foo"].Size()); EXPECT_EQ(1u, d["foo"].Size());
EXPECT_STREQ("baz", d["foo"][0].GetString()); EXPECT_STREQ("baz", d["foo"][0].GetString());
...@@ -881,6 +883,24 @@ TEST(Pointer, Erase) { ...@@ -881,6 +883,24 @@ TEST(Pointer, Erase) {
EXPECT_TRUE(d["foo"].Empty()); EXPECT_TRUE(d["foo"].Empty());
EXPECT_TRUE(Pointer("/foo").Erase(d)); EXPECT_TRUE(Pointer("/foo").Erase(d));
EXPECT_TRUE(Pointer("/foo").Get(d) == 0); EXPECT_TRUE(Pointer("/foo").Get(d) == 0);
Pointer("/a/0/b/0").Create(d);
EXPECT_TRUE(Pointer("/a/0/b/0").Get(d) != 0);
EXPECT_TRUE(Pointer("/a/0/b/0").Erase(d));
EXPECT_TRUE(Pointer("/a/0/b/0").Get(d) == 0);
EXPECT_TRUE(Pointer("/a/0/b").Get(d) != 0);
EXPECT_TRUE(Pointer("/a/0/b").Erase(d));
EXPECT_TRUE(Pointer("/a/0/b").Get(d) == 0);
EXPECT_TRUE(Pointer("/a/0").Get(d) != 0);
EXPECT_TRUE(Pointer("/a/0").Erase(d));
EXPECT_TRUE(Pointer("/a/0").Get(d) == 0);
EXPECT_TRUE(Pointer("/a").Get(d) != 0);
EXPECT_TRUE(Pointer("/a").Erase(d));
EXPECT_TRUE(Pointer("/a").Get(d) == 0);
} }
TEST(Pointer, CreateValueByPointer) { TEST(Pointer, CreateValueByPointer) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment