From 0adb053294045adcba5643d82983ed90e9816d1e Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Sat, 23 Mar 2019 14:16:13 +0100 Subject: [PATCH] tests: Add small checks for find() --- src/test_lib_json/main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 2df51b5..c2d0f2e 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -204,6 +204,16 @@ JSONTEST_FIXTURE(ValueTest, objects) { JSONTEST_ASSERT_EQUAL(Json::Value(1234), constObject["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 JSONTEST_ASSERT_EQUAL(Json::Value(1234), object1_["id"]); JSONTEST_ASSERT_EQUAL(Json::Value(), object1_["unknown id"]);