2 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28 {"xn-invalid", "xn-invalid"},
31 {"xn--caff-8oa", "caffè"},
32 {"xn--nave-6pa", "naïve"},
33 {"xn--e-0mbbc", "τeστ"},
34 {"xn--8ca67lbac", "τèστ"},
35 {"xn--28j2a3ar1p", "こんにちは"},
36 {"xn--hello--ur7iy09x", "hello-世界"},
37 {"xn--hi--hi-rr7iy09x", "hi-世界-hi"},
38 {"xn--caf-8la.foo.org", "cafè.foo.org"},
43 {"xn--x73laaa", "𩸽𩸽𩸽𩸽"},
48 sandbox_logger_process(void)
50 /* to make the linker happy! */
55 main(int argc, char **argv)
57 const struct suite *i;
59 char buf[64]; /* name len */
60 const char *parse_err;
63 for (i = t; i->src != NULL; ++i) {
64 memset(buf, 0, sizeof(buf));
65 if (!puny_decode(i->src, buf, sizeof(buf), &parse_err)) {
66 printf("decode: failure with %s: %s\n",
72 if (strcmp(buf, i->res)) {
73 printf("ERR: expected \"%s\", got \"%s\"\n",
78 printf("OK: %s => %s\n", i->src, buf);