test get(key, default)

This commit is contained in:
Christopher Dunn 2015-03-05 16:44:41 -06:00
parent f50145fbda
commit d31151d150
2 changed files with 4 additions and 1 deletions

View File

@ -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);
}

View File

@ -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());
}
}