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.
This commit is contained in:
parent
dd4b80a5f6
commit
27ca12e815
@ -153,10 +153,22 @@ test_contains (cjson_t needle, cjson_t hay)
|
||||
nonnull (needle->string));
|
||||
}
|
||||
if (test_contains (needle->child, hay->child))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needle->prev)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user