1 #include <ccan/json_escape/json_escape.h>
2 /* Include the C files directly. */
3 #include <ccan/json_escape/json_escape.c>
4 #include <ccan/tap/tap.h>
8 const tal_t *ctx = tal(NULL, char);
11 /* This is how many tests you plan to run */
14 e = json_escape(ctx, "Hello");
15 ok1(!strcmp(e->s, "Hello"));
16 ok1(!strcmp(json_escape_unescape(ctx, e),
21 "\\\\\\b\\f\\n\\r\\t\\\"");
23 "\\\\\\b\\f\\n\\r\\t\\\""
24 "\\\\\\\\\\\\b\\\\f\\\\n\\\\r\\\\t\\\\\\\""));
25 ok1(!strcmp(json_escape_unescape(ctx, e),
27 "\\\\\\b\\f\\n\\r\\t\\\""));
29 /* This one doesn't escape the already-escaped chars */
30 e = json_partial_escape(ctx,
32 "\\\\\\b\\f\\n\\r\\t\\\"");
34 "\\\\\\b\\f\\n\\r\\t\\\""
35 "\\\\\\b\\f\\n\\r\\t\\\""));
36 ok1(!strcmp(json_escape_unescape(ctx, e),
42 /* This exits depending on whether all tests passed */