From 9a1f7ea8029ff518d81ed7f13000a7c0bddcca5c Mon Sep 17 00:00:00 2001 From: jobol Date: Mon, 11 Jun 2018 14:28:01 +0200 Subject: wrap-json: new helper functions for comparison The new functions are - wrap_json_clone_depth: clone with defined depth - wrap_json_sort: sort an array accordingly to wrap_json_cmp - wrap_json_keys: compute the array of sorted keys - wrap_json_cmp: compare 2 items - wrap_json_equal: test equallity - wrap_json_contains: test inclusion Change-Id: I9787bff6c262fa2702c27802d771e2d487ce6309 Signed-off-by: jose bollo --- wrap-json.test.result | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) (limited to 'wrap-json.test.result') diff --git a/wrap-json.test.result b/wrap-json.test.result index 0edaf75..899059b 100644 --- a/wrap-json.test.result +++ b/wrap-json.test.result @@ -409,3 +409,93 @@ unpack("{\"foo\":\"\"}", "{s?y}", "foo", &xy[0], &xz[0]) unpack("{}", "{s?y}", "foo", &xy[0], &xz[0]) SUCCESS s:foo y/0: +compare(null)(null) + -> 0 / 1 + +compare(true)(true) + -> 0 / 1 + +compare(false)(false) + -> 0 / 1 + +compare(1)(1) + -> 0 / 1 + +compare(1.0)(1.0) + -> 0 / 1 + +compare("")("") + -> 0 / 1 + +compare("hi")("hi") + -> 0 / 1 + +compare({})({}) + -> 0 / 1 + +compare({"a":true,"b":false})({"b":false,"a":true}) + -> 0 / 1 + +compare([])([]) + -> 0 / 1 + +compare([1,true,null])([1,true,null]) + -> 0 / 1 + +compare(null)(true) + -> -1 / 0 + +compare(null)(false) + -> -1 / 0 + +compare(0)(1) + -> -1 / 0 + +compare(1)(0) + -> 1 / 0 + +compare(0)(true) + -> 2 / 0 + +compare(0)(false) + -> 2 / 0 + +compare(0)(null) + -> 3 / 0 + +compare("hi")("hello") + -> 4 / 0 + +compare("hello")("hi") + -> -4 / 0 + +compare({})(null) + -> 4 / 0 + +compare({})(true) + -> 3 / 0 + +compare({})(1) + -> 1 / 0 + +compare({})(1.0) + -> 2 / 0 + +compare({})([]) + -> -1 / 0 + +compare({})("x") + -> -2 / 0 + +compare([1,true,null])([1,true]) + -> 1 / 1 + +compare({"a":true,"b":false})({"a":true}) + -> 1 / 1 + +compare({"a":true,"b":false})({"a":true,"c":false}) + -> -1 / 0 + +compare({"a":true,"c":false})({"a":true,"b":false}) + -> 1 / 0 + -- cgit 1.2.3-korg