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);
12 /* This is how many tests you plan to run */
15 /* This should simply be tal_steal */
16 p = tal_dup_arr(NULL, char, "Hello", 6, 0);
17 e = json_escape(ctx, take(p));
18 ok1(!strcmp(e->s, "Hello"));
19 ok1((void *)e == (void *)p);
20 ok1(tal_parent(e) == ctx);
22 /* This can't be tal_steal, but still should be freed. */
23 p = tal_dup_arr(NULL, char,
25 "\\\\\\b\\f\\n\\r\\t\\\"", 22, 0);
26 e = json_escape(ctx, take(p));
27 ok1(tal_parent(e) == ctx);
29 "\\\\\\b\\f\\n\\r\\t\\\""
30 "\\\\\\\\\\\\b\\\\f\\\\n\\\\r\\\\t\\\\\\\""));
33 /* This exits depending on whether all tests passed */