mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-26 18:51:04 +08:00
test get(key, default)
This commit is contained in:
parent
f50145fbda
commit
d31151d150
@ -1037,7 +1037,7 @@ Value Value::get(char const* key, Value const& defaultValue) const
|
||||
}
|
||||
Value Value::get(std::string const& key, Value const& defaultValue) const
|
||||
{
|
||||
return get(key.c_str(), defaultValue);
|
||||
return get(key.data(), key.data() + key.length(), defaultValue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1578,6 +1578,7 @@ JSONTEST_FIXTURE(ValueTest, zeroesInKeys) {
|
||||
JSONTEST_ASSERT_STRING_EQUAL("there", root[binary].asString());
|
||||
JSONTEST_ASSERT(!root.isMember("hi"));
|
||||
JSONTEST_ASSERT(root.isMember(binary));
|
||||
JSONTEST_ASSERT_STRING_EQUAL("there", root.get(binary, Json::Value::nullRef).asString());
|
||||
Json::Value removed;
|
||||
bool did;
|
||||
did = root.removeMember(binary.data(), binary.data() + binary.length(),
|
||||
@ -1588,6 +1589,8 @@ JSONTEST_FIXTURE(ValueTest, zeroesInKeys) {
|
||||
&removed);
|
||||
JSONTEST_ASSERT(!did);
|
||||
JSONTEST_ASSERT_STRING_EQUAL("there", removed.asString()); // still
|
||||
JSONTEST_ASSERT(!root.isMember(binary));
|
||||
JSONTEST_ASSERT_STRING_EQUAL("", root.get(binary, Json::Value::nullRef).asString());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user