From 01fe61276ef321b222897118e0a5f99bdc7bf885 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Wed, 6 Mar 2024 00:49:55 +0000 Subject: [PATCH] Add unit test for semicolon in value --- test/unit_test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/unit_test.c b/test/unit_test.c index 7665e99e43..fc90d98f57 100644 --- a/test/unit_test.c +++ b/test/unit_test.c @@ -2861,7 +2861,7 @@ static void test_json(void) { const char *s1 = "{\"a\":{},\"b\":7,\"c\":[[],2]}"; const char *s2 = "{\"a\":{\"b1\":{}},\"c\":7,\"d\":{\"b2\":{}}}"; int n; - struct mg_str json; + struct mg_str json, val; ASSERT(mg_json_get(mg_str_n(" true ", 6), "", &n) == MG_JSON_INVALID); ASSERT(mg_json_get(mg_str_n(" true ", 6), "$", &n) == 1 && n == 4); @@ -3053,6 +3053,10 @@ static void test_json(void) { ASSERT(mg_vcmp(&v, "42") == 0); ASSERT(mg_json_next(sub, 15, &k, &v) == 0); } + + json = mg_str("{\"a\":\"b:c\"}"); + val = mg_json_get_tok(json, "$.a"); + ASSERT(mg_strcmp(val, mg_str("\"b:c\"")) == 0); } static void resp_rpc(struct mg_rpc_req *r) {