Skip to content

Commit 0adb053

Browse files
committed
tests: Add small checks for find()
1 parent 863aa36 commit 0adb053

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/test_lib_json/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@ JSONTEST_FIXTURE(ValueTest, objects) {
204204
JSONTEST_ASSERT_EQUAL(Json::Value(1234), constObject["id"]);
205205
JSONTEST_ASSERT_EQUAL(Json::Value(), constObject["unknown id"]);
206206

207+
// Access through find()
208+
const char idKey[] = "id";
209+
const Json::Value* foundId = object1_.find(idKey, idKey + strlen(idKey));
210+
JSONTEST_ASSERT(foundId != nullptr);
211+
JSONTEST_ASSERT_EQUAL(Json::Value(1234), *foundId);
212+
213+
const char unknownIdKey[] = "unknown id";
214+
const Json::Value* foundUnknownId = object1_.find(unknownIdKey, unknownIdKey + strlen(unknownIdKey));
215+
JSONTEST_ASSERT_EQUAL(nullptr, foundUnknownId);
216+
207217
// Access through non-const reference
208218
JSONTEST_ASSERT_EQUAL(Json::Value(1234), object1_["id"]);
209219
JSONTEST_ASSERT_EQUAL(Json::Value(), object1_["unknown id"]);

0 commit comments

Comments
 (0)