Skip to content

Commit d31151d

Browse files
committed
test get(key, default)
1 parent f50145f commit d31151d

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/lib_json/json_value.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ Value Value::get(char const* key, Value const& defaultValue) const
10371037
}
10381038
Value Value::get(std::string const& key, Value const& defaultValue) const
10391039
{
1040-
return get(key.c_str(), defaultValue);
1040+
return get(key.data(), key.data() + key.length(), defaultValue);
10411041
}
10421042

10431043

src/test_lib_json/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,7 @@ JSONTEST_FIXTURE(ValueTest, zeroesInKeys) {
15781578
JSONTEST_ASSERT_STRING_EQUAL("there", root[binary].asString());
15791579
JSONTEST_ASSERT(!root.isMember("hi"));
15801580
JSONTEST_ASSERT(root.isMember(binary));
1581+
JSONTEST_ASSERT_STRING_EQUAL("there", root.get(binary, Json::Value::nullRef).asString());
15811582
Json::Value removed;
15821583
bool did;
15831584
did = root.removeMember(binary.data(), binary.data() + binary.length(),
@@ -1588,6 +1589,8 @@ JSONTEST_FIXTURE(ValueTest, zeroesInKeys) {
15881589
&removed);
15891590
JSONTEST_ASSERT(!did);
15901591
JSONTEST_ASSERT_STRING_EQUAL("there", removed.asString()); // still
1592+
JSONTEST_ASSERT(!root.isMember(binary));
1593+
JSONTEST_ASSERT_STRING_EQUAL("", root.get(binary, Json::Value::nullRef).asString());
15911594
}
15921595
}
15931596

0 commit comments

Comments
 (0)