aboutsummaryrefslogtreecommitdiffstats
path: root/tests/json
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2018-11-14 14:17:18 +0000
committerAndre Heinecke <[email protected]>2018-11-14 14:17:18 +0000
commit27ca12e815c0a582d357641a04b889d648b8766e (patch)
tree70774d0bd7dd24528e16a92dee4437cf96907fe8 /tests/json
parenttests,json: Add the bulk of tests (diff)
downloadgpgme-27ca12e815c0a582d357641a04b889d648b8766e.tar.gz
gpgme-27ca12e815c0a582d357641a04b889d648b8766e.zip
tests,json: Fix match if the first child differs
* tests/json/t-json.c (test_contains): Try all siblings of the haystack child. -- This fixes the case where we don't match against the first child because the order might have changed or a new element was inserted at the top. Then we have to try out also all the siblings.
Diffstat (limited to 'tests/json')
-rw-r--r--tests/json/t-json.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/json/t-json.c b/tests/json/t-json.c
index 1f45febd..7a4d9065 100644
--- a/tests/json/t-json.c
+++ b/tests/json/t-json.c
@@ -154,7 +154,19 @@ test_contains (cjson_t needle, cjson_t hay)
}
if (test_contains (needle->child, hay->child))
{
- return 1;
+ int found = 0;
+ for (cjson_t hit = hay->child; hit; hit = hit->next)
+ {
+ found |= !test_contains (needle->child, hit);
+ if (found)
+ {
+ break;
+ }
+ }
+ if (!found)
+ {
+ return 1;
+ }
}
}