@@ -204,6 +204,26 @@ 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+
217+ // Access through demand()
218+ const char yetAnotherIdKey[] = " yet another id" ;
219+ const Json::Value* foundYetAnotherId = object1_.find (yetAnotherIdKey, yetAnotherIdKey + strlen (yetAnotherIdKey));
220+ JSONTEST_ASSERT_EQUAL (nullptr , foundYetAnotherId);
221+ Json::Value* demandedYetAnotherId = object1_.demand (yetAnotherIdKey, yetAnotherIdKey + strlen (yetAnotherIdKey));
222+ JSONTEST_ASSERT (demandedYetAnotherId != nullptr );
223+ *demandedYetAnotherId = " baz" ;
224+
225+ JSONTEST_ASSERT_EQUAL (Json::Value (" baz" ), object1_[" yet another id" ]);
226+
207227 // Access through non-const reference
208228 JSONTEST_ASSERT_EQUAL (Json::Value (1234 ), object1_[" id" ]);
209229 JSONTEST_ASSERT_EQUAL (Json::Value (), object1_[" unknown id" ]);
0 commit comments