From 9a31fdcb11d04d47dfcc38a8409b84436c549108 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Wed, 14 Nov 2018 14:57:40 +0100 Subject: [PATCH] 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. --- tests/json/t-json.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/json/t-json.c b/tests/json/t-json.c index 07b99847..f5b27939 100644 --- a/tests/json/t-json.c +++ b/tests/json/t-json.c @@ -125,7 +125,9 @@ test_contains (cjson_t needle, cjson_t hay) } 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) fprintf (stderr, "%s: string mismatch Expected '%s' got '%s'\n",