1 /* Common code for AI_IDN/NI_IDN tests.
2 Copyright (C) 2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 /* Before including this file, TEST_USE_UTF8 must be defined to 1 or
20 0, depending on whether a UTF-8 locale is used or a Latin-1
26 #include <support/check.h>
27 #include <support/check_nss.h>
28 #include <support/resolv_test.h>
29 #include <support/support.h>
31 /* Name of the shared object for libidn2. */
32 #define LIBIDN2_SONAME "libidn2.so.0"
35 /* UTF-8 encoding of "nämchen" (German for “namelet”). */
36 # define NAEMCHEN "n\xC3\xA4mchen"
38 /* UTF-8 encoding of "שם" (Hebrew for “name”). */
39 # define SHEM "\xD7\xA9\xD7\x9D"
41 /* UTF-8 encoding of "buße" (German for “penance”). This used to be
42 encoded as "busse" (“busses”) in IDNA2003. */
43 # define BUSSE "bu\xC3\x9F""e"
46 /* Latin-1 encodings, as far as they are available. */
48 # define NAEMCHEN "n\xE4mchen"
49 # define BUSSE "bu\xDF""e"
53 /* IDNA encoding of NAEMCHEN. */
54 #define NAEMCHEN_IDNA "xn--nmchen-bua"
56 /* IDNA encoding of NAEMCHEN "_zwo". */
57 #define NAEMCHEN_ZWO_IDNA "xn--nmchen_zwo-q5a"
59 /* IDNA encoding of SHEM. */
60 #define SHEM_IDNA "xn--iebx"
62 /* IDNA encoding of BUSSE. */
63 #define BUSSE_IDNA "xn--bue-6ka"
65 /* IDNA encoding of "שם1". */
66 #define SHEM1_IDNA "xn--1-qic9a"
68 /* Another IDNA name. */
69 #define ANDERES_NAEMCHEN "anderes-" NAEMCHEN
70 #define ANDERES_NAEMCHEN_IDNA "xn--anderes-nmchen-eib"
72 /* Controls the kind of test data in a PTR lookup response. */
76 gni_non_idn_cname_to_non_idn_name
,
77 gni_non_idn_cname_to_idn_name
,
81 gni_idn_cname_to_non_idn_name
,
82 gni_idn_cname_to_idn_name
,
87 /* Called from response below. The LSB (first byte) controls what
88 goes into the response, see enum gni_test. */
90 response_ptr (const struct resolv_response_context
*ctx
,
91 struct resolv_response_builder
*b
, const char *qname
)
94 TEST_COMPARE (sscanf (qname
, "%d.%d.%d.%d.in-addr.arpa",
95 &comp
[0], &comp
[1], &comp
[2], &comp
[3]), 4);
96 const char *next_name
;
97 switch ((enum gni_test
) comp
[0])
99 /* First name in response is non-IDN name. */
100 case gni_non_idn_name
:
101 resolv_response_open_record (b
, qname
, C_IN
, T_PTR
, 0);
102 resolv_response_add_name (b
, "non-idn.example");
103 resolv_response_close_record (b
);
105 case gni_non_idn_cname_to_non_idn_name
:
106 resolv_response_open_record (b
, qname
, C_IN
, T_CNAME
, 0);
107 next_name
= "non-idn-cname.example";
108 resolv_response_add_name (b
, next_name
);
109 resolv_response_close_record (b
);
110 resolv_response_open_record (b
, next_name
, C_IN
, T_PTR
, 0);
111 resolv_response_add_name (b
, "non-idn-name.example");
112 resolv_response_close_record (b
);
114 case gni_non_idn_cname_to_idn_name
:
115 resolv_response_open_record (b
, qname
, C_IN
, T_CNAME
, 0);
116 next_name
= "non-idn-cname.example";
117 resolv_response_add_name (b
, next_name
);
118 resolv_response_close_record (b
);
119 resolv_response_open_record (b
, next_name
, C_IN
, T_PTR
, 0);
120 resolv_response_add_name (b
, NAEMCHEN_IDNA
".example");
121 resolv_response_close_record (b
);
124 /* First name in response is IDN name. */
126 resolv_response_open_record (b
, qname
, C_IN
, T_PTR
, 0);
127 resolv_response_add_name (b
, "xn--nmchen-bua.example");
128 resolv_response_close_record (b
);
131 resolv_response_open_record (b
, qname
, C_IN
, T_PTR
, 0);
132 resolv_response_add_name (b
, SHEM_IDNA
".example");
133 resolv_response_close_record (b
);
136 resolv_response_open_record (b
, qname
, C_IN
, T_PTR
, 0);
137 resolv_response_add_name (b
, SHEM1_IDNA
".example");
138 resolv_response_close_record (b
);
140 case gni_idn_cname_to_non_idn_name
:
141 resolv_response_open_record (b
, qname
, C_IN
, T_CNAME
, 0);
142 next_name
= NAEMCHEN_IDNA
".example";
143 resolv_response_add_name (b
, next_name
);
144 resolv_response_close_record (b
);
145 resolv_response_open_record (b
, next_name
, C_IN
, T_PTR
, 0);
146 resolv_response_add_name (b
, "non-idn-name.example");
147 resolv_response_close_record (b
);
149 case gni_idn_cname_to_idn_name
:
150 resolv_response_open_record (b
, qname
, C_IN
, T_CNAME
, 0);
151 next_name
= NAEMCHEN_IDNA
".example";
152 resolv_response_add_name (b
, next_name
);
153 resolv_response_close_record (b
);
154 resolv_response_open_record (b
, next_name
, C_IN
, T_PTR
, 0);
155 resolv_response_add_name (b
, ANDERES_NAEMCHEN_IDNA
".example");
156 resolv_response_close_record (b
);
159 /* Invalid IDN encodings. */
160 case gni_invalid_idn_1
:
161 resolv_response_open_record (b
, qname
, C_IN
, T_PTR
, 0);
162 resolv_response_add_name (b
, "xn---.example");
163 resolv_response_close_record (b
);
165 case gni_invalid_idn_2
:
166 resolv_response_open_record (b
, qname
, C_IN
, T_PTR
, 0);
167 resolv_response_add_name (b
, "xn--x.example");
168 resolv_response_close_record (b
);
171 FAIL_EXIT1 ("invalid PTR query: %s", qname
);
174 /* For PTR responses, see above. A/AAAA queries can request
175 additional CNAMEs in the response by include ".cname." and
176 ".idn-cname." in the query. The LSB in the address contains the
177 first byte of the QNAME. */
179 response (const struct resolv_response_context
*ctx
,
180 struct resolv_response_builder
*b
,
181 const char *qname
, uint16_t qclass
, uint16_t qtype
)
183 TEST_VERIFY_EXIT (qclass
== C_IN
);
185 for (const char *p
= qname
; *p
!= '\0'; ++p
)
186 if (!(('0' <= *p
&& *p
<= '9')
187 || ('a' <= *p
&& *p
<= 'z')
188 || ('A' <= *p
&& *p
<= 'Z')
189 || *p
== '.' || *p
== '-' || *p
== '_'))
191 /* Non-ASCII query. Reply with NXDOMAIN. */
192 struct resolv_response_flags flags
= { .rcode
= 3 };
193 resolv_response_init (b
, flags
);
194 resolv_response_add_question (b
, qname
, qclass
, qtype
);
198 struct resolv_response_flags flags
= { 0 };
199 resolv_response_init (b
, flags
);
200 resolv_response_add_question (b
, qname
, qclass
, qtype
);
201 resolv_response_section (b
, ns_s_an
);
205 response_ptr (ctx
, b
, qname
);
209 bool with_cname
= strstr (qname
, ".cname.") != NULL
;
210 bool with_idn_cname
= strstr (qname
, ".idn-cname.") != NULL
;
212 const char *next_name
= qname
;
215 next_name
= "non-idn-cname.example";
216 resolv_response_open_record (b
, qname
, C_IN
, T_CNAME
, 0);
217 resolv_response_add_name (b
, next_name
);
218 resolv_response_close_record (b
);
222 next_name
= ANDERES_NAEMCHEN_IDNA
".example";
223 resolv_response_open_record (b
, qname
, C_IN
, T_CNAME
, 0);
224 resolv_response_add_name (b
, next_name
);
225 resolv_response_close_record (b
);
228 resolv_response_open_record (b
, next_name
, C_IN
, qtype
, 0);
233 char addr
[4] = { 192, 0, 2, qname
[0] };
234 resolv_response_add_data (b
, &addr
, sizeof (addr
));
240 = { 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
242 resolv_response_add_data (b
, &addr
, sizeof (addr
));
245 FAIL_EXIT1 ("invalid qtype: %d", qtype
);
247 resolv_response_close_record (b
);
250 /* Check the result of a getaddrinfo call. */
252 check_ai (const char *name
, int ai_flags
, const char *expected
)
254 struct addrinfo hints
=
256 .ai_flags
= ai_flags
,
257 .ai_family
= AF_INET
,
258 .ai_socktype
= SOCK_STREAM
,
261 char *query
= xasprintf ("%s:80 AF_INET/0x%x", name
, ai_flags
);
262 int ret
= getaddrinfo (name
, "80", &hints
, &ai
);
263 check_addrinfo (query
, ai
, ret
, expected
);
269 /* Run one getnameinfo test. FLAGS is automatically augmented with
272 gni_test (enum gni_test code
, unsigned int flags
, const char *expected
)
274 struct sockaddr_in sin
=
276 .sin_family
= AF_INET
,
277 .sin_port
= htons (80),
278 .sin_addr
= { htonl (0xc0000200 | code
) }, /* 192.0.2.0/24 network. */
282 int ret
= getnameinfo ((const struct sockaddr
*) &sin
, sizeof (sin
),
283 host
, sizeof (host
), service
, sizeof (service
),
284 flags
| NI_NUMERICSERV
);
287 if (expected
== NULL
)
288 TEST_COMPARE (ret
, EAI_IDN_ENCODE
);
291 support_record_failure ();
292 printf ("error: getnameinfo failed (code %d, flags 0x%x): %s (%d)\n",
293 (int) code
, flags
, gai_strerror (ret
), ret
);
296 else if (ret
== 0 && expected
== NULL
)
298 support_record_failure ();
299 printf ("error: getnameinfo unexpected success (code %d, flags 0x%x)\n",
302 else if (strcmp (host
, expected
) != 0 || strcmp (service
, "80") != 0)
304 support_record_failure ();
305 printf ("error: getnameinfo test failure (code %d, flags 0x%x)\n"
306 " expected host: \"%s\"\n"
307 " expected service: \"80\"\n"
308 " actual host: \"%s\"\n"
309 " actual service: \"%s\"\n",
310 (int) code
, flags
, expected
, host
, service
);
314 /* Tests for getaddrinfo which assume a working libidn2 library. */
315 __attribute__ ((unused
))
317 gai_tests_with_libidn2 (void)
320 check_ai ("non-idn.example", 0,
321 "address: STREAM/TCP 192.0.2.110 80\n");
322 check_ai ("non-idn.example", AI_IDN
,
324 "address: STREAM/TCP 192.0.2.110 80\n");
325 check_ai ("non-idn.example", AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
326 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
327 "canonname: non-idn.example\n"
328 "address: STREAM/TCP 192.0.2.110 80\n");
330 check_ai (NAEMCHEN
".example", 0,
331 "error: Name or service not known\n");
332 check_ai (NAEMCHEN
".example", AI_IDN
,
334 "address: STREAM/TCP 192.0.2.120 80\n");
335 check_ai (NAEMCHEN
".example", AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
336 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
337 "canonname: " NAEMCHEN
".example\n"
338 "address: STREAM/TCP 192.0.2.120 80\n");
341 check_ai (SHEM
".example", 0,
342 "error: Name or service not known\n");
343 check_ai (SHEM
".example", AI_IDN
,
345 "address: STREAM/TCP 192.0.2.120 80\n");
346 check_ai (SHEM
".example", AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
347 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
348 "canonname: " SHEM
".example\n"
349 "address: STREAM/TCP 192.0.2.120 80\n");
350 check_ai (SHEM
".example", AI_IDN
| AI_CANONNAME
,
351 "flags: AI_CANONNAME AI_IDN\n"
352 "canonname: " SHEM_IDNA
".example\n"
353 "address: STREAM/TCP 192.0.2.120 80\n");
354 check_ai (SHEM
"1.example", AI_IDN
,
356 "address: STREAM/TCP 192.0.2.120 80\n");
357 check_ai (SHEM
"1.example", AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
358 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
359 "canonname: " SHEM
"1.example\n"
360 "address: STREAM/TCP 192.0.2.120 80\n");
361 check_ai (SHEM
"1.example", AI_IDN
| AI_CANONNAME
,
362 "flags: AI_CANONNAME AI_IDN\n"
363 "canonname: " SHEM1_IDNA
".example\n"
364 "address: STREAM/TCP 192.0.2.120 80\n");
367 /* Check that non-transitional mode is active. German sharp S
368 should not turn into SS. */
369 check_ai (BUSSE
".example", 0,
370 "error: Name or service not known\n");
371 check_ai (BUSSE
".example", AI_IDN
,
373 "address: STREAM/TCP 192.0.2.120 80\n");
374 check_ai (BUSSE
".example", AI_IDN
| AI_CANONNAME
,
375 "flags: AI_CANONNAME AI_IDN\n"
376 "canonname: " BUSSE_IDNA
".example\n"
377 "address: STREAM/TCP 192.0.2.120 80\n");
378 check_ai (BUSSE
".example", AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
379 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
380 "canonname: " BUSSE
".example\n"
381 "address: STREAM/TCP 192.0.2.120 80\n");
383 /* Check that Unicode TR 46 mode is active. Underscores should be
384 permitted in IDNA components. */
385 check_ai (NAEMCHEN
"_zwo.example", 0,
386 "error: Name or service not known\n");
387 check_ai (NAEMCHEN
"_zwo.example", AI_IDN
,
389 "address: STREAM/TCP 192.0.2.120 80\n");
390 check_ai (NAEMCHEN
"_zwo.example", AI_IDN
| AI_CANONNAME
,
391 "flags: AI_CANONNAME AI_IDN\n"
392 "canonname: " NAEMCHEN_ZWO_IDNA
".example\n"
393 "address: STREAM/TCP 192.0.2.120 80\n");
394 check_ai (NAEMCHEN
"_zwo.example", AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
395 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
396 "canonname: " NAEMCHEN
"_zwo.example\n"
397 "address: STREAM/TCP 192.0.2.120 80\n");
399 /* No CNAME, but already IDN-encoded. */
400 check_ai (NAEMCHEN_IDNA
".example", 0,
401 "address: STREAM/TCP 192.0.2.120 80\n");
402 check_ai (NAEMCHEN_IDNA
".example", AI_IDN
,
404 "address: STREAM/TCP 192.0.2.120 80\n");
405 check_ai (NAEMCHEN_IDNA
".example", AI_IDN
| AI_CANONNAME
,
406 "flags: AI_CANONNAME AI_IDN\n"
407 "canonname: " NAEMCHEN_IDNA
".example\n"
408 "address: STREAM/TCP 192.0.2.120 80\n");
409 check_ai (NAEMCHEN_IDNA
".example", AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
410 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
411 "canonname: " NAEMCHEN
".example\n"
412 "address: STREAM/TCP 192.0.2.120 80\n");
413 check_ai (SHEM_IDNA
".example", 0,
414 "address: STREAM/TCP 192.0.2.120 80\n");
415 check_ai (SHEM_IDNA
".example", AI_IDN
,
417 "address: STREAM/TCP 192.0.2.120 80\n");
418 check_ai (SHEM_IDNA
".example", AI_IDN
| AI_CANONNAME
,
419 "flags: AI_CANONNAME AI_IDN\n"
420 "canonname: " SHEM_IDNA
".example\n"
421 "address: STREAM/TCP 192.0.2.120 80\n");
423 check_ai (SHEM_IDNA
".example", AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
424 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
425 "canonname: " SHEM
".example\n"
426 "address: STREAM/TCP 192.0.2.120 80\n");
428 check_ai (SHEM_IDNA
".example", AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
429 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
430 "canonname: " SHEM_IDNA
".example\n"
431 "address: STREAM/TCP 192.0.2.120 80\n");
434 /* Invalid IDNA canonical name is returned as-is. */
435 check_ai ("xn---.example", AI_CANONNAME
| AI_CANONIDN
,
436 "flags: AI_CANONNAME AI_CANONIDN\n"
437 "canonname: xn---.example\n"
438 "address: STREAM/TCP 192.0.2.120 80\n");
441 check_ai ("with.cname.example", 0,
442 "address: STREAM/TCP 192.0.2.119 80\n");
443 check_ai ("with.cname.example", AI_IDN
,
445 "address: STREAM/TCP 192.0.2.119 80\n");
446 check_ai ("with.cname.example", AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
447 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
448 "canonname: non-idn-cname.example\n"
449 "address: STREAM/TCP 192.0.2.119 80\n");
451 check_ai ("with.cname." NAEMCHEN
".example", 0,
452 "error: Name or service not known\n");
453 check_ai ("with.cname." NAEMCHEN
".example", AI_IDN
,
455 "address: STREAM/TCP 192.0.2.119 80\n");
456 check_ai ("with.cname." NAEMCHEN
".example", AI_IDN
| AI_CANONNAME
,
457 "flags: AI_CANONNAME AI_IDN\n"
458 "canonname: non-idn-cname.example\n"
459 "address: STREAM/TCP 192.0.2.119 80\n");
460 check_ai ("with.cname." NAEMCHEN
".example",
461 AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
462 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
463 "canonname: non-idn-cname.example\n"
464 "address: STREAM/TCP 192.0.2.119 80\n");
467 check_ai ("With.idn-cname.example", 0,
468 "address: STREAM/TCP 192.0.2.87 80\n");
469 check_ai ("With.idn-cname.example", AI_IDN
,
471 "address: STREAM/TCP 192.0.2.87 80\n");
472 check_ai ("With.idn-cname.example", AI_IDN
| AI_CANONNAME
,
473 "flags: AI_CANONNAME AI_IDN\n"
474 "canonname: " ANDERES_NAEMCHEN_IDNA
".example\n"
475 "address: STREAM/TCP 192.0.2.87 80\n");
476 check_ai ("With.idn-cname.example",
477 AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
478 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
479 "canonname: " ANDERES_NAEMCHEN
".example\n"
480 "address: STREAM/TCP 192.0.2.87 80\n");
482 check_ai ("With.idn-cname." NAEMCHEN
".example", 0,
483 "error: Name or service not known\n");
484 check_ai ("With.idn-cname." NAEMCHEN
".example", AI_IDN
,
486 "address: STREAM/TCP 192.0.2.119 80\n");
487 check_ai ("With.idn-cname." NAEMCHEN
".example", AI_IDN
| AI_CANONNAME
,
488 "flags: AI_CANONNAME AI_IDN\n"
489 "canonname: " ANDERES_NAEMCHEN_IDNA
".example\n"
490 "address: STREAM/TCP 192.0.2.119 80\n");
491 check_ai ("With.idn-cname." NAEMCHEN
".example",
492 AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
493 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
494 "canonname: " ANDERES_NAEMCHEN
".example\n"
495 "address: STREAM/TCP 192.0.2.119 80\n");
497 /* Non-IDN to IDN CNAME chain. */
498 check_ai ("both.cname.idn-cname.example", 0,
499 "address: STREAM/TCP 192.0.2.98 80\n");
500 check_ai ("both.cname.idn-cname.example", AI_IDN
,
502 "address: STREAM/TCP 192.0.2.98 80\n");
503 check_ai ("both.cname.idn-cname.example", AI_IDN
| AI_CANONNAME
,
504 "flags: AI_CANONNAME AI_IDN\n"
505 "canonname: " ANDERES_NAEMCHEN_IDNA
".example\n"
506 "address: STREAM/TCP 192.0.2.98 80\n");
507 check_ai ("both.cname.idn-cname.example",
508 AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
509 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
510 "canonname: " ANDERES_NAEMCHEN
".example\n"
511 "address: STREAM/TCP 192.0.2.98 80\n");
513 check_ai ("both.cname.idn-cname." NAEMCHEN
".example", 0,
514 "error: Name or service not known\n");
515 check_ai ("both.cname.idn-cname." NAEMCHEN
".example", AI_IDN
,
517 "address: STREAM/TCP 192.0.2.98 80\n");
518 check_ai ("both.cname.idn-cname." NAEMCHEN
".example",
519 AI_IDN
| AI_CANONNAME
,
520 "flags: AI_CANONNAME AI_IDN\n"
521 "canonname: " ANDERES_NAEMCHEN_IDNA
".example\n"
522 "address: STREAM/TCP 192.0.2.98 80\n");
523 check_ai ("both.cname.idn-cname." NAEMCHEN
".example",
524 AI_IDN
| AI_CANONNAME
| AI_CANONIDN
,
525 "flags: AI_CANONNAME AI_IDN AI_CANONIDN\n"
526 "canonname: " ANDERES_NAEMCHEN
".example\n"
527 "address: STREAM/TCP 192.0.2.98 80\n");
530 /* Tests for getnameinfo which assume a working libidn2 library. */
531 __attribute__ ((unused
))
533 gni_tests_with_libidn2 (void)
535 gni_test (gni_non_idn_name
, 0, "non-idn.example");
536 gni_test (gni_non_idn_name
, NI_IDN
, "non-idn.example");
537 gni_test (gni_non_idn_name
, NI_NUMERICHOST
, "192.0.2.0");
538 gni_test (gni_non_idn_name
, NI_NUMERICHOST
| NI_IDN
, "192.0.2.0");
540 gni_test (gni_non_idn_cname_to_non_idn_name
, 0, "non-idn-name.example");
541 gni_test (gni_non_idn_cname_to_non_idn_name
, NI_IDN
, "non-idn-name.example");
543 gni_test (gni_non_idn_cname_to_idn_name
, 0, NAEMCHEN_IDNA
".example");
544 gni_test (gni_non_idn_cname_to_idn_name
, NI_IDN
, NAEMCHEN
".example");
546 gni_test (gni_idn_name
, 0, NAEMCHEN_IDNA
".example");
547 gni_test (gni_idn_name
, NI_IDN
, NAEMCHEN
".example");
548 gni_test (gni_idn_shem
, 0, SHEM_IDNA
".example");
549 gni_test (gni_idn_shem1
, 0, SHEM1_IDNA
".example");
551 gni_test (gni_idn_shem
, NI_IDN
, SHEM
".example");
552 gni_test (gni_idn_shem1
, NI_IDN
, SHEM
"1.example");
554 gni_test (gni_idn_shem
, NI_IDN
, SHEM_IDNA
".example");
555 gni_test (gni_idn_shem1
, NI_IDN
, SHEM1_IDNA
".example");
558 gni_test (gni_idn_cname_to_non_idn_name
, 0, "non-idn-name.example");
559 gni_test (gni_idn_cname_to_non_idn_name
, NI_IDN
, "non-idn-name.example");
561 gni_test (gni_idn_cname_to_idn_name
, 0, ANDERES_NAEMCHEN_IDNA
".example");
562 gni_test (gni_idn_cname_to_idn_name
, NI_IDN
, ANDERES_NAEMCHEN
".example");
564 /* Test encoding errors. */
565 gni_test (gni_invalid_idn_1
, 0, "xn---.example");
566 gni_test (gni_invalid_idn_1
, NI_IDN
, "xn---.example");
567 gni_test (gni_invalid_idn_2
, 0, "xn--x.example");
568 gni_test (gni_invalid_idn_2
, NI_IDN
, "xn--x.example");