tests,json: Add wildcard string matching

* tests/json/t-json.c (test_contains): When searching for "*" accept
every string.

--
This allows it to write tests that check for the existence of
a string value but don't care about the contents. E.g. for Data.
This commit is contained in:
Andre Heinecke 2018-11-14 14:57:40 +01:00
parent e55e467d5f
commit 9a31fdcb11
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C

View File

@ -125,7 +125,9 @@ test_contains (cjson_t needle, cjson_t hay)
} }
if (cjson_is_string (needle)) if (cjson_is_string (needle))
{ {
if (strcmp (needle->valuestring, hay->valuestring)) if (strcmp (needle->valuestring, hay->valuestring) &&
/* Use * as a general don't care placeholder */
strcmp (needle->valuestring, "*"))
{ {
if (verbose) if (verbose)
fprintf (stderr, "%s: string mismatch Expected '%s' got '%s'\n", fprintf (stderr, "%s: string mismatch Expected '%s' got '%s'\n",