mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-28 20:15:24 +08:00
tests: Add small checks for find()
This commit is contained in:
parent
863aa36165
commit
0adb053294
@ -204,6 +204,16 @@ JSONTEST_FIXTURE(ValueTest, objects) {
|
|||||||
JSONTEST_ASSERT_EQUAL(Json::Value(1234), constObject["id"]);
|
JSONTEST_ASSERT_EQUAL(Json::Value(1234), constObject["id"]);
|
||||||
JSONTEST_ASSERT_EQUAL(Json::Value(), constObject["unknown id"]);
|
JSONTEST_ASSERT_EQUAL(Json::Value(), constObject["unknown id"]);
|
||||||
|
|
||||||
|
// Access through find()
|
||||||
|
const char idKey[] = "id";
|
||||||
|
const Json::Value* foundId = object1_.find(idKey, idKey + strlen(idKey));
|
||||||
|
JSONTEST_ASSERT(foundId != nullptr);
|
||||||
|
JSONTEST_ASSERT_EQUAL(Json::Value(1234), *foundId);
|
||||||
|
|
||||||
|
const char unknownIdKey[] = "unknown id";
|
||||||
|
const Json::Value* foundUnknownId = object1_.find(unknownIdKey, unknownIdKey + strlen(unknownIdKey));
|
||||||
|
JSONTEST_ASSERT_EQUAL(nullptr, foundUnknownId);
|
||||||
|
|
||||||
// Access through non-const reference
|
// Access through non-const reference
|
||||||
JSONTEST_ASSERT_EQUAL(Json::Value(1234), object1_["id"]);
|
JSONTEST_ASSERT_EQUAL(Json::Value(1234), object1_["id"]);
|
||||||
JSONTEST_ASSERT_EQUAL(Json::Value(), object1_["unknown id"]);
|
JSONTEST_ASSERT_EQUAL(Json::Value(), object1_["unknown id"]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user