X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftest_json.c;h=e294d93e88d24221157c3d2b9a9b61489c1402a2;hp=eace27e40d9df806fecfb7a76cbd4bb8e6f91486;hb=0d6f3ee9720647761ff74414a46828c0b9711ac0;hpb=3107ce3a34993d2f784387f227a50343fff83bbc diff --git a/test/test_json.c b/test/test_json.c index eace27e..e294d93 100644 --- a/test/test_json.c +++ b/test/test_json.c @@ -1,13 +1,21 @@ +/* This file is part of the YAZ toolkit. + * Copyright (C) Index Data + * See the file LICENSE for details. + */ /** - * \file + * \file * \brief JSON test */ +#if HAVE_CONFIG_H +#include +#endif + #include #include #include #include -static int expect(json_parser_t p, const char *input, +static int expect(json_parser_t p, const char *input, const char *output) { int ret = 0; @@ -76,7 +84,7 @@ static void tst1(void) YAZ_CHECK(expect(p, "{} extra", 0)); YAZ_CHECK(expect(p, "{\"a\":[1,2,3}", 0)); - + YAZ_CHECK(expect(p, "{\"a\":[1,2,", 0)); YAZ_CHECK(expect(p, "{\"k\":\"wa\"}", "{\"k\":\"wa\"}")); @@ -110,9 +118,24 @@ static void tst1(void) YAZ_CHECK(expect(p, "{\"a\":[1,2,3]}", "{\"a\":[1,2,3]}")); - YAZ_CHECK(expect(p, "{\"k\":\"\\t\"}", "{\"k\":\"\x09\"}")); + YAZ_CHECK(expect(p, "{\"k\":\"\\t\"}", "{\"k\":\"\\t\"}")); + YAZ_CHECK(expect(p, "{\"k\":\"\t\"}", "{\"k\":\"\\t\"}")); + + YAZ_CHECK(expect(p, "{\"k\":\"\\n\"}", "{\"k\":\"\\n\"}")); + YAZ_CHECK(expect(p, "{\"k\":\"\n\"}", "{\"k\":\"\\n\"}")); - YAZ_CHECK(expect(p, "{\"k\":\"\\u0009\"}", "{\"k\":\"\x09\"}")); + YAZ_CHECK(expect(p, "{\"k\":\"\\r\"}", "{\"k\":\"\\r\"}")); + YAZ_CHECK(expect(p, "{\"k\":\"\r\"}", "{\"k\":\"\\r\"}")); + + YAZ_CHECK(expect(p, "{\"k\":\"\\f\"}", "{\"k\":\"\\f\"}")); + YAZ_CHECK(expect(p, "{\"k\":\"\f\"}", "{\"k\":\"\\f\"}")); + + YAZ_CHECK(expect(p, "{\"k\":\"\\b\"}", "{\"k\":\"\\b\"}")); + YAZ_CHECK(expect(p, "{\"k\":\"\b\"}", "{\"k\":\"\\b\"}")); + + YAZ_CHECK(expect(p, + "{\"k\":\"\\u0001\\u0002\"}", + "{\"k\":\"\\u0001\\u0002\"}")); json_parser_destroy(p); } @@ -127,7 +150,7 @@ static void tst2(void) return; YAZ_CHECK_EQ(json_count_children(n), 3); - + n1 = json_get_object(n, "a"); YAZ_CHECK(n1 && n1->type == json_node_number && n1->u.number == 1.0); YAZ_CHECK_EQ(json_count_children(n1), 0);