2 static char *rcsid = "Id: api.tsy,v 1.1 2003/06/04 00:26:50 marka Exp ";
6 * Copyright (c) 2002 Japan Network Information Center.
9 * By using this file, you agree to the terms and conditions set forth bellow.
11 * LICENSE TERMS AND CONDITIONS
13 * The following License Terms and Conditions apply, unless a different
14 * license is obtained from Japan Network Information Center ("JPNIC"),
15 * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
16 * Chiyoda-ku, Tokyo 101-0047, Japan.
18 * 1. Use, Modification and Redistribution (including distribution of any
19 * modified or derived work) in source and/or binary forms is permitted
20 * under this License Terms and Conditions.
22 * 2. Redistribution of source code must retain the copyright notices as they
23 * appear in each source code file, this License Terms and Conditions.
25 * 3. Redistribution in binary form must reproduce the Copyright Notice,
26 * this License Terms and Conditions, in the documentation and/or other
27 * materials provided with the distribution. For the purposes of binary
28 * distribution the "Copyright Notice" refers to the following language:
29 * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
31 * 4. The name of JPNIC may not be used to endorse or promote products
32 * derived from this Software without specific prior written approval of
35 * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
36 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
38 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
41 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
43 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
44 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
45 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
58 #ifndef EUCJP_ENCODING_NAME
59 #define EUCJP_ENCODING_NAME "eucJP"
63 * U+304B: hiragana letter KA
64 * U+3099: combining katakana-hiragana voiced sound mark
66 * map("U+304B U+3099") -> "U+304C"
68 * U+304C: hiragana letter GA
70 #define UTF8_NAME "A<U+304B><U+3099>"
71 #define UTF8_REVNAME "a<U+304C>"
74 * A4AC: hiragana letter GA (in EUC-JP)
76 #define EUCJP_NAME "\xa4\xac"
77 #define EUCJP_REVNAME "\xa4\xac"
80 * Conversion result of "U+304B U+3099 A"
82 #define PUNYCODE_NAME "xn--a-i8t"
85 * Conversion result of "A U+304B U+3099" (in EUC-JP).
87 #define AUX_EUCJP_NAME "xn--a-i\xa3\xb8t"
90 //--------------------------------------------------------------------
91 // Setups and Teardowns.
92 //--------------------------------------------------------------------
95 // group: generic-conversion
97 // Initialize the `api' module.
98 // Set local encoding to `UTF-8'.
103 setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
104 unsetenv("IDN_DISABLE");
111 // Set log level to `fatal' to supress log messages.
115 saved_log_level = idn_log_getlevel();
116 idn_log_setlevel(idn_log_level_fatal);
122 // Restore log level.
124 idn_log_setlevel(saved_log_level);
127 //--------------------------------------------------------------------
129 //--------------------------------------------------------------------
132 // title: basic conversion by encodename()
133 // group: generic-conversion
135 r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
136 ASSERT_RESULT(r, idn_success);
137 ASSERT_STRING(to, PUNYCODE_NAME);
141 // title: basic conversion by decodename()
142 // group: generic-conversion
144 r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
145 ASSERT_RESULT(r, idn_success);
146 ASSERT_STRING(to, UTF8_REVNAME);
150 // title: basic conversion by decodename2()
151 // group: generic-conversion
153 r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
154 EUCJP_ENCODING_NAME);
156 ASSERT_RESULT(r, idn_failure);
158 ASSERT_RESULT(r, idn_success);
159 ASSERT_STRING(to, UTF8_REVNAME);
164 // title: call decodename2() with auxencoding=NULL
165 // group: generic-conversion
170 r = idn_decodename2(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to),
172 ASSERT_RESULT(r, idn_success);
173 ASSERT_STRING(to, UTF8_REVNAME);
178 // title: call encodename() with actions=0
179 // group: generic-conversion
181 r = idn_encodename(0, UTF8_NAME, to, sizeof(to));
182 ASSERT_RESULT(r, idn_success);
183 ASSERT_STRING(to, UTF8_NAME);
187 // title: call decodename() with actions=0
188 // group: generic-conversion
190 r = idn_decodename(0, PUNYCODE_NAME, to, sizeof(to));
191 ASSERT_RESULT(r, idn_success);
192 ASSERT_STRING(to, PUNYCODE_NAME);
196 // title: call decodename2() with actions=0
197 // group: generic-conversion
202 r = idn_decodename2(0, AUX_EUCJP_NAME, to, sizeof(to),
203 EUCJP_ENCODING_NAME);
204 ASSERT_RESULT(r, idn_success);
205 ASSERT_STRING(to, AUX_EUCJP_NAME);
210 // title: call encodename() with actions=rtcheck
211 // group: generic-conversion quiet
213 r = idn_encodename(IDN_RTCHECK, EUCJP_NAME, to, sizeof(to));
214 ASSERT_RESULT(r, idn_invalid_action);
218 // title: call encodename() with actions=decode-query
219 // group: generic-conversion quiet
221 r = idn_encodename(IDN_DECODE_QUERY, EUCJP_NAME, to, sizeof(to));
222 ASSERT_RESULT(r, idn_invalid_action);
226 // title: call encodename() with actions=decode-app
227 // group: generic-conversion quiet
229 r = idn_encodename(IDN_DECODE_APP, EUCJP_NAME, to, sizeof(to));
230 ASSERT_RESULT(r, idn_invalid_action);
234 // title: call encodename() with actions=decode-stored
235 // group: generic-conversion quiet
237 r = idn_encodename(IDN_DECODE_STORED, EUCJP_NAME, to, sizeof(to));
238 ASSERT_RESULT(r, idn_invalid_action);
242 // title: call encodename() with actions=(1<<31)
243 // group: generic-conversion quiet
245 r = idn_encodename(1 << 31, EUCJP_NAME, to, sizeof(to));
246 ASSERT_RESULT(r, idn_invalid_action);
250 // title: call decodename() with actions=localmap
251 // group: generic-conversion quiet
253 r = idn_decodename(IDN_LOCALMAP, PUNYCODE_NAME, to, sizeof(to));
254 ASSERT_RESULT(r, idn_invalid_action);
258 // title: call decodename2() with actions=localmap
259 // group: generic-conversion quiet
264 r = idn_decodename2(IDN_LOCALMAP, AUX_EUCJP_NAME, to, sizeof(to),
265 EUCJP_ENCODING_NAME);
266 ASSERT_RESULT(r, idn_invalid_action);
271 // title: call decodename() with actions=lencheck
272 // group: generic-conversion quiet
274 r = idn_decodename(IDN_LENCHECK, PUNYCODE_NAME, to, sizeof(to));
275 ASSERT_RESULT(r, idn_invalid_action);
279 // title: call decodename2() with actions=lencheck
280 // group: generic-conversion quiet
285 r = idn_decodename2(IDN_LENCHECK, AUX_EUCJP_NAME, to, sizeof(to),
286 EUCJP_ENCODING_NAME);
287 ASSERT_RESULT(r, idn_invalid_action);
292 // title: call decodename() with actions=encode-query
293 // group: generic-conversion quiet
295 r = idn_decodename(IDN_ENCODE_QUERY, PUNYCODE_NAME, to, sizeof(to));
296 ASSERT_RESULT(r, idn_invalid_action);
300 // title: call decodename2() with actions=encode-query
301 // group: generic-conversion quiet
306 r = idn_decodename2(IDN_ENCODE_QUERY, AUX_EUCJP_NAME, to, sizeof(to),
307 EUCJP_ENCODING_NAME);
308 ASSERT_RESULT(r, idn_invalid_action);
313 // title: call decodename() with actions=encode-app
314 // group: generic-conversion quiet
316 r = idn_decodename(IDN_ENCODE_APP, PUNYCODE_NAME, to, sizeof(to));
317 ASSERT_RESULT(r, idn_invalid_action);
321 // title: call decodename2() with actions=encode-app
322 // group: generic-conversion quiet
327 r = idn_decodename2(IDN_ENCODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
328 EUCJP_ENCODING_NAME);
329 ASSERT_RESULT(r, idn_invalid_action);
334 // title: call decodename() with actions=encode-stored
335 // group: generic-conversion quiet
337 r = idn_decodename(IDN_ENCODE_STORED, PUNYCODE_NAME, to, sizeof(to));
338 ASSERT_RESULT(r, idn_invalid_action);
342 // title: call decodename2() with actions=encode-stored
343 // group: generic-conversion quiet
348 r = idn_decodename2(IDN_ENCODE_STORED, AUX_EUCJP_NAME, to, sizeof(to),
349 EUCJP_ENCODING_NAME);
350 ASSERT_RESULT(r, idn_invalid_action);
355 // title: call decodename() with actions=(1<<31)
356 // group: generic-conversion quiet
358 r = idn_decodename(1 << 31, PUNYCODE_NAME, to, sizeof(to));
359 ASSERT_RESULT(r, idn_invalid_action);
363 // title: call decodename2() with actions=(1<<31)
364 // group: generic-conversion quiet
369 r = idn_decodename2(1 << 31, AUX_EUCJP_NAME, to, sizeof(to),
370 EUCJP_ENCODING_NAME);
371 ASSERT_RESULT(r, idn_invalid_action);
376 // title: call encodename() with actions=localconv
377 // group: generic-conversion quiet
379 #ifndef WITHOUT_ICONV
382 r = idn_encodename(IDN_LOCALCONV, UTF8_NAME, to, sizeof(to));
383 ASSERT_RESULT(r, idn_invalid_action);
388 // title: call decodename() with actions=localconv
389 // group: generic-conversion quiet
391 #ifndef WITHOUT_ICONV
394 r = idn_decodename(IDN_LOCALCONV, PUNYCODE_NAME, to, sizeof(to));
395 ASSERT_RESULT(r, idn_invalid_action);
400 // title: call decodename2() with actions=localconv
401 // group: generic-conversion
403 #ifndef WITHOUT_ICONV
406 r = idn_decodename2(IDN_LOCALCONV, AUX_EUCJP_NAME, to, sizeof(to),
407 EUCJP_ENCODING_NAME);
408 ASSERT_RESULT(r, idn_failure);
413 // title: call enable(0) and then encodename()
414 // group: generic-conversion
417 r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
418 ASSERT_RESULT(r, idn_success);
419 ASSERT_STRING(to, UTF8_NAME);
423 // title: call decodename() when IDN_DISABLE is defined
424 // group: generic-conversion
427 r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
428 ASSERT_RESULT(r, idn_success);
429 ASSERT_STRING(to, PUNYCODE_NAME);
433 // title: call decodename() when IDN_DISABLE is defined
434 // group: generic-conversion
440 r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
441 EUCJP_ENCODING_NAME);
442 ASSERT_RESULT(r, idn_success);
443 ASSERT_STRING(to, AUX_EUCJP_NAME);
448 // title: call enable(0) and then encodename()
449 // group: generic-conversion
452 r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
453 ASSERT_RESULT(r, idn_success);
454 ASSERT_STRING(to, UTF8_NAME);
458 // title: call enable(0) and then decodename()
459 // group: generic-conversion
462 r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
463 ASSERT_RESULT(r, idn_success);
464 ASSERT_STRING(to, PUNYCODE_NAME);
468 // title: call enable(0) and then decodename2()
469 // group: generic-conversion
475 r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
476 EUCJP_ENCODING_NAME);
477 ASSERT_RESULT(r, idn_success);
478 ASSERT_STRING(to, AUX_EUCJP_NAME);
483 // title: set IDN_DISABLE and call encodename()
484 // group: generic-conversion
486 setenv("IDN_DISABLE", "1", 1);
487 r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
488 ASSERT_RESULT(r, idn_success);
489 ASSERT_STRING(to, UTF8_NAME);
493 // title: set IDN_DISABLE and call decodename()
494 // group: generic-conversion
496 setenv("IDN_DISABLE", "1", 1);
497 r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
498 ASSERT_RESULT(r, idn_success);
499 ASSERT_STRING(to, PUNYCODE_NAME);
503 // title: set IDN_DISABLE and call decodename2()
504 // group: generic-conversion
509 setenv("IDN_DISABLE", "1", 1);
510 r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
511 EUCJP_ENCODING_NAME);
512 ASSERT_RESULT(r, idn_success);
513 ASSERT_STRING(to, AUX_EUCJP_NAME);
518 // title: set IDN_DISABLE, and then call enable(1) and encodename()
519 // group: generic-conversion
521 setenv("IDN_DISABLE", "1", 1);
523 r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
524 ASSERT_RESULT(r, idn_success);
525 ASSERT_STRING(to, PUNYCODE_NAME);
529 // title: set IDN_DISABLE, and then call enable(1) and decodename()
530 // group: generic-conversion
532 setenv("IDN_DISABLE", "1", 1);
534 r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
535 ASSERT_RESULT(r, idn_success);
536 ASSERT_STRING(to, UTF8_REVNAME);
540 // title: set IDN_DISABLE, and then call enable(1) and decodename2()
541 // group: generic-conversion
546 setenv("IDN_DISABLE", "1", 1);
548 r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
549 EUCJP_ENCODING_NAME);
550 ASSERT_RESULT(r, idn_success);
551 ASSERT_STRING(to, UTF8_REVNAME);
556 // title: overrun test for arg `to' of encodename()
557 // group: generic-conversion
560 r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to,
561 strlen(PUNYCODE_NAME) + 1);
562 ASSERT_RESULT(r, idn_success);
563 ASSERT_STRING(to, PUNYCODE_NAME);
565 r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to,
566 strlen(PUNYCODE_NAME));
567 ASSERT_RESULT(r, idn_buffer_overflow);
571 r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to,
572 strlen(UTF8_NAME) + 1);
573 ASSERT_RESULT(r, idn_success);
574 ASSERT_STRING(to, UTF8_NAME);
576 r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to,
578 ASSERT_RESULT(r, idn_buffer_overflow);
582 r = idn_encodename(0, UTF8_NAME, to, strlen(UTF8_NAME) + 1);
583 ASSERT_RESULT(r, idn_success);
584 ASSERT_STRING(to, UTF8_NAME);
586 r = idn_encodename(0, UTF8_NAME, to, strlen(UTF8_NAME));
587 ASSERT_RESULT(r, idn_buffer_overflow);
591 // title: overrun test for arg `to' of decodename()
592 // group: generic-conversion
595 r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to,
596 strlen(UTF8_REVNAME) + 1);
597 ASSERT_RESULT(r, idn_success);
598 ASSERT_STRING(to, UTF8_REVNAME);
600 r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to,
601 strlen(UTF8_REVNAME));
602 ASSERT_RESULT(r, idn_buffer_overflow);
604 /* idn_enable(0) case */
606 r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to,
607 strlen(PUNYCODE_NAME) + 1);
608 ASSERT_RESULT(r, idn_success);
609 ASSERT_STRING(to, PUNYCODE_NAME);
611 r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to,
612 strlen(PUNYCODE_NAME));
613 ASSERT_RESULT(r, idn_buffer_overflow);
617 r = idn_decodename(0, PUNYCODE_NAME, to, strlen(PUNYCODE_NAME) + 1);
618 ASSERT_RESULT(r, idn_success);
619 ASSERT_STRING(to, PUNYCODE_NAME);
621 r = idn_decodename(0, PUNYCODE_NAME, to, strlen(PUNYCODE_NAME));
622 ASSERT_RESULT(r, idn_buffer_overflow);
626 // title: overrun test for arg `to' of decodename2()
627 // group: generic-conversion
633 r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to,
634 strlen(UTF8_REVNAME) + 1, EUCJP_ENCODING_NAME);
635 ASSERT_RESULT(r, idn_success);
636 ASSERT_STRING(to, UTF8_REVNAME);
638 r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to,
639 strlen(UTF8_REVNAME), EUCJP_ENCODING_NAME);
640 ASSERT_RESULT(r, idn_buffer_overflow);
642 /* idn_enable(0) case */
644 r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to,
645 strlen(AUX_EUCJP_NAME) + 1, EUCJP_ENCODING_NAME);
646 ASSERT_RESULT(r, idn_success);
647 ASSERT_STRING(to, AUX_EUCJP_NAME);
649 r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to,
650 strlen(AUX_EUCJP_NAME), EUCJP_ENCODING_NAME);
651 ASSERT_RESULT(r, idn_buffer_overflow);
655 r = idn_decodename2(0, AUX_EUCJP_NAME, to, strlen(AUX_EUCJP_NAME) + 1,
656 EUCJP_ENCODING_NAME);
657 ASSERT_RESULT(r, idn_success);
658 ASSERT_STRING(to, AUX_EUCJP_NAME);
660 r = idn_decodename2(0, AUX_EUCJP_NAME, to, strlen(AUX_EUCJP_NAME),
661 EUCJP_ENCODING_NAME);
662 ASSERT_RESULT(r, idn_buffer_overflow);
668 // title: call encodename() with tolen=0
669 // group: generic-conversion
671 r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, 0);
672 ASSERT_RESULT(r, idn_buffer_overflow);
676 // title: call decodename() with tolen=0
677 // group: generic-conversion
679 r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, 0);
680 ASSERT_RESULT(r, idn_buffer_overflow);
684 // title: call decodename2() with tolen=0
685 // group: generic-conversion
690 r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, 0,
691 EUCJP_ENCODING_NAME);
692 ASSERT_RESULT(r, idn_buffer_overflow);
697 // title: convert an empty string using encodename()
698 // group: generic-conversion
700 r = idn_encodename(IDN_ENCODE_APP, "", to, sizeof(to));
701 ASSERT_RESULT(r, idn_success);
702 ASSERT_STRING(to, "");
706 // title: convert an empty string using decodename()
707 // group: generic-conversion
709 r = idn_decodename(IDN_DECODE_APP, "", to, sizeof(to));
710 ASSERT_RESULT(r, idn_success);
711 ASSERT_STRING(to, "");
715 // title: convert an empty string using decodename2()
716 // group: generic-conversion
721 r = idn_decodename2(IDN_DECODE_APP, "", to, sizeof(to),
722 EUCJP_ENCODING_NAME);
723 ASSERT_RESULT(r, idn_success);
724 ASSERT_STRING(to, "");
729 // title: prohcheck by encodename()
730 // group: generic-conversion
732 /* U+1680: prohibited character */
733 r = idn_encodename(IDN_PROHCHECK, "<U+1680>", to, sizeof(to));
734 ASSERT_RESULT(r, idn_prohibited);
738 // title: unascheck by encodename()
739 // group: generic-conversion
741 /* U+0221: unassigned codepoint */
742 r = idn_encodename(IDN_UNASCHECK, "<U+0221>", to, sizeof(to));
743 ASSERT_RESULT(r, idn_prohibited);
747 // title: bidicheck by encodename()
748 // group: generic-conversion
750 /* U+05D0: bidirectional property is "R" */
751 /* `a': bidirectional property is "L" */
752 /* `0', `-': bidirectional property is "N" */
753 r = idn_encodename(IDN_BIDICHECK, "<U+05D0>", to, sizeof(to));
754 ASSERT_RESULT(r, idn_success);
756 r = idn_encodename(IDN_BIDICHECK, "<U+05D0><U+05D0>",
758 ASSERT_RESULT(r, idn_success);
760 r = idn_encodename(IDN_BIDICHECK, "<U+05D0><U+05D0>-a",
762 ASSERT_RESULT(r, idn_prohibited);
764 r = idn_encodename(IDN_BIDICHECK, "<U+05D0>-a-<U+05D0>",
766 ASSERT_RESULT(r, idn_prohibited);
768 r = idn_encodename(IDN_BIDICHECK, "a-<U+05D0><U+05D0>",
770 ASSERT_RESULT(r, idn_prohibited);
772 r = idn_encodename(IDN_BIDICHECK, "<U+05D0><U+05D0>-0",
774 ASSERT_RESULT(r, idn_prohibited);
776 r = idn_encodename(IDN_BIDICHECK, "<U+05D0>-0-<U+05D0>",
778 ASSERT_RESULT(r, idn_success);
780 r = idn_encodename(IDN_BIDICHECK, "0-<U+05D0><U+05D0>",
782 ASSERT_RESULT(r, idn_prohibited);
786 // title: asccheck by encodename()
787 // group: generic-conversion
789 r = idn_encodename(IDN_ASCCHECK, "-name", to, sizeof(to));
790 ASSERT_RESULT(r, idn_prohibited);
792 r = idn_encodename(IDN_ASCCHECK, "name-", to, sizeof(to));
793 ASSERT_RESULT(r, idn_prohibited);
795 r = idn_encodename(IDN_ASCCHECK, "n ame", to, sizeof(to));
796 ASSERT_RESULT(r, idn_prohibited);
800 // title: lencheck by encodename()
801 // group: generic-conversion
803 r = idn_encodename(IDN_LENCHECK,
804 "123456789-123456789-123456789-123456789-"
805 "123456789-123456789-123", to, sizeof(to));
806 ASSERT_RESULT(r, idn_success);
808 r = idn_encodename(IDN_LENCHECK,
809 "123456789-123456789-123456789-123456789-"
810 "123456789-123456789-1234", to, sizeof(to));
811 ASSERT_RESULT(r, idn_invalid_length);
813 r = idn_encodename(IDN_LENCHECK, "a..b", to, sizeof(to));
814 ASSERT_RESULT(r, idn_invalid_length);
818 // title: rtcheck non-prohchecked label by decodename()
819 // group: generic-conversion
821 /* "xn--6ue" -> "U+1680" (prohibited character) */
822 r = idn_decodename(IDN_RTCHECK, "xn--6ue", to, sizeof(to));
823 ASSERT_RESULT(r, idn_success);
824 ASSERT_STRING(to, "xn--6ue");
828 // title: rtcheck non-unaschecked label by decodename()
829 // group: generic-conversion
831 /* "xn--6la" -> "U+0221" (unassigned codepoint) */
832 r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK,
833 "xn--6la", to, sizeof(to));
834 ASSERT_RESULT(r, idn_success);
835 ASSERT_STRING(to, "xn--6la");
839 // title: rtcheck non-ascchecked label by decodename()
840 // group: generic-conversion
842 /* "xn----x7t" -> "- U+3042" */
843 r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
844 "xn----x7t", to, sizeof(to));
845 ASSERT_RESULT(r, idn_success);
846 ASSERT_STRING(to, "xn----x7t");
848 /* "xn----w7t" -> "U+3042 -" */
849 r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
850 "xn----w7t", to, sizeof(to));
851 ASSERT_RESULT(r, idn_success);
852 ASSERT_STRING(to, "xn----w7t");
856 // title: rtcheck non-lenchecked label by decodename()
857 // group: generic-conversion
859 /* `s1' has 63 characters */
861 "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
864 "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>"
865 "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>"
866 "<U+5DDD><U+3042><U+3042><U+3042>";
868 /* `s2' has 64 characters */
870 "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
872 /* `s3' has an empty label */
873 const char *s3 = "a..b";
875 r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to));
876 ASSERT_RESULT(r, idn_success);
877 ASSERT_STRING(to, s1rev);
879 r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to));
880 ASSERT_RESULT(r, idn_success);
881 ASSERT_STRING(to, s2);
883 r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to));
884 ASSERT_RESULT(r, idn_success);
885 ASSERT_STRING(to, s3);
889 // title: rtcheck non-prohchecked label by decodename2()
890 // group: generic-conversion
895 /* "xn--6ue" -> "U+1680" (prohibited character) */
896 r = idn_decodename2(IDN_RTCHECK, "xn--6ue", to, sizeof(to),
897 EUCJP_ENCODING_NAME);
898 ASSERT_RESULT(r, idn_success);
899 ASSERT_STRING(to, "xn--6ue");
904 // title: rtcheck non-unaschecked label by decodename2()
905 // group: generic-conversion
910 /* "xn--6la" -> "U+0221" (unassigned codepoint) */
911 r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK,
912 "xn--6la", to, sizeof(to), EUCJP_ENCODING_NAME);
913 ASSERT_RESULT(r, idn_success);
914 ASSERT_STRING(to, "xn--6la");
919 // title: rtcheck non-ascchecked label by decodename2()
920 // group: generic-conversion
925 /* "xn----x7t" -> "- U+3042" */
926 r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
927 "xn----x7t", to, sizeof(to), EUCJP_ENCODING_NAME);
929 ASSERT_RESULT(r, idn_success);
930 ASSERT_STRING(to, "xn----x7t");
932 /* "xn----w7t" -> "U+3042 -" */
933 r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
934 "xn----w7t", to, sizeof(to), EUCJP_ENCODING_NAME);
935 ASSERT_RESULT(r, idn_success);
936 ASSERT_STRING(to, "xn----w7t");
941 // title: rtcheck non-lenchecked label by decodename2()
942 // group: generic-conversion
947 /* `s1' has 63 characters */
949 "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
952 "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>"
953 "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>"
954 "<U+5DDD><U+3042><U+3042><U+3042>";
956 /* `s2' has 64 characters */
958 "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
960 /* `s3' has an empty label */
961 const char *s3 = "a..b";
963 r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to),
964 EUCJP_ENCODING_NAME);
965 ASSERT_RESULT(r, idn_success);
966 ASSERT_STRING(to, s1rev);
968 r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to),
969 EUCJP_ENCODING_NAME);
970 ASSERT_RESULT(r, idn_success);
971 ASSERT_STRING(to, s2);
973 r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to));
974 ASSERT_RESULT(r, idn_success);
975 ASSERT_STRING(to, s3);
980 // title: pass broken string as `from' to encodename()
981 // group: generic-conversion quiet
983 /* "\xe3\x21" is not valid UTF-8 string */
984 r = idn_encodename(IDN_ENCODE_APP, "\xe3\x21", to, sizeof(to));
985 ASSERT_RESULT(r, idn_invalid_encoding);
989 // title: pass broken string as `from' to decodename()
990 // group: generic-conversion quiet
992 /* "\xe3\x21" is not valid UTF-8 string */
993 r = idn_decodename(IDN_DECODE_APP, "\xe3\x21", to, sizeof(to));
994 ASSERT_RESULT(r, idn_invalid_encoding);
998 // title: pass broken string as `from' to decodename2()
999 // group: generic-conversion quiet
1001 #ifdef WITHOUT_ICONV
1004 /* "\xa4\x21" is not valid EUC-JP string */
1005 r = idn_decodename2(IDN_DECODE_APP, "\xa4\x21", to, sizeof(to),
1006 EUCJP_ENCODING_NAME);
1007 ASSERT_RESULT(r, idn_invalid_encoding);