From e893625e88f02539b9cd03e591df3ee8970552c3 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Tue, 20 Jan 2015 16:54:27 -0600 Subject: [PATCH] test removeIndex/Member() --- src/test_lib_json/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 08ef66a..98fb8d0 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -198,6 +198,14 @@ JSONTEST_FIXTURE(ValueTest, objects) { object1_["some other id"] = "foo"; JSONTEST_ASSERT_EQUAL(Json::Value("foo"), object1_["some other id"]); + JSONTEST_ASSERT_EQUAL(Json::Value("foo"), object1_["some other id"]); + + // Remove. + Json::Value got; + got = object1_.removeMember("some other id"); + JSONTEST_ASSERT_EQUAL(Json::Value("foo"), got); + got = object1_.removeMember("some other id"); + JSONTEST_ASSERT_EQUAL(Json::nullValue, got); } JSONTEST_FIXTURE(ValueTest, arrays) { @@ -240,6 +248,10 @@ JSONTEST_FIXTURE(ValueTest, arrays) { array1_[2] = Json::Value(17); JSONTEST_ASSERT_EQUAL(Json::Value(), array1_[1]); JSONTEST_ASSERT_EQUAL(Json::Value(17), array1_[2]); + Json::Value got; + JSONTEST_ASSERT_EQUAL(true, array1_.removeIndex(2, &got)); + JSONTEST_ASSERT_EQUAL(Json::Value(17), got); + JSONTEST_ASSERT_EQUAL(false, array1_.removeIndex(2, &got)); // gone now } JSONTEST_FIXTURE(ValueTest, null) {