+/* 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 <config.h>
+#endif
+
#include <yaz/test.h>
#include <yaz/json.h>
#include <string.h>
#include <yaz/log.h>
-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;
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\"}"));
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);
}
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);