From 227c7cdfa55c977cdee02ddba09c80dff8130595 Mon Sep 17 00:00:00 2001 From: Vincent Date: Thu, 26 Sep 2019 05:07:34 +0800 Subject: [PATCH] Supplement the testcase for comparing object (#1032) * supplement the testcase for comparing object * update testcase * add a new test scenarios in compareObject --- src/test_lib_json/main.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 83fab4e..7b9abaf 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -1463,16 +1463,41 @@ JSONTEST_FIXTURE(ValueTest, compareObject) { Json::Value l1aObject; l1aObject["key1"] = 0; Json::Value l1bObject; - l1aObject["key1"] = 10; + l1bObject["key1"] = 10; Json::Value l2aObject; l2aObject["key1"] = 0; l2aObject["key2"] = 0; + Json::Value l2bObject; + l2bObject["key1"] = 10; + l2bObject["key2"] = 0; JSONTEST_ASSERT_PRED(checkIsLess(emptyObject, l1aObject)); - JSONTEST_ASSERT_PRED(checkIsLess(emptyObject, l2aObject)); - JSONTEST_ASSERT_PRED(checkIsLess(l1aObject, l2aObject)); + JSONTEST_ASSERT_PRED(checkIsLess(l1aObject, l1bObject)); + JSONTEST_ASSERT_PRED(checkIsLess(l1bObject, l2aObject)); + JSONTEST_ASSERT_PRED(checkIsLess(l2aObject, l2bObject)); JSONTEST_ASSERT_PRED(checkIsEqual(emptyObject, Json::Value(emptyObject))); JSONTEST_ASSERT_PRED(checkIsEqual(l1aObject, Json::Value(l1aObject))); + JSONTEST_ASSERT_PRED(checkIsEqual(l1bObject, Json::Value(l1bObject))); JSONTEST_ASSERT_PRED(checkIsEqual(l2aObject, Json::Value(l2aObject))); + JSONTEST_ASSERT_PRED(checkIsEqual(l2bObject, Json::Value(l2bObject))); + { + Json::Value aObject; + aObject["a"] = 10; + Json::Value bObject; + bObject["b"] = 0; + Json::Value cObject; + cObject["c"] = 20; + cObject["f"] = 15; + Json::Value dObject; + dObject["d"] = -2; + dObject["e"] = 10; + JSONTEST_ASSERT_PRED(checkIsLess(aObject, bObject)); + JSONTEST_ASSERT_PRED(checkIsLess(bObject, cObject)); + JSONTEST_ASSERT_PRED(checkIsLess(cObject, dObject)); + JSONTEST_ASSERT_PRED(checkIsEqual(aObject, Json::Value(aObject))); + JSONTEST_ASSERT_PRED(checkIsEqual(bObject, Json::Value(bObject))); + JSONTEST_ASSERT_PRED(checkIsEqual(cObject, Json::Value(cObject))); + JSONTEST_ASSERT_PRED(checkIsEqual(dObject, Json::Value(dObject))); + } } JSONTEST_FIXTURE(ValueTest, compareType) {