Skip to content

Commit

Permalink
Improve coverage of Pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
miloyip committed May 21, 2015
1 parent 3229566 commit f688b2b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/unittest/pointertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,14 +873,34 @@ TEST(Pointer, Erase) {
d.Parse(kJson);

EXPECT_FALSE(Pointer("").Erase(d));
EXPECT_FALSE(Pointer("/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_EQ(1u, d["foo"].Size());
EXPECT_STREQ("baz", d["foo"][0].GetString());
EXPECT_TRUE(Pointer("/foo/0").Erase(d));
EXPECT_TRUE(d["foo"].Empty());
EXPECT_TRUE(Pointer("/foo").Erase(d));
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) {
Expand Down

0 comments on commit f688b2b

Please sign in to comment.