OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * | 3 * |
4 * Copyright (C) 2003-2013, International Business Machines | 4 * Copyright (C) 2003-2014, International Business Machines |
5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
6 * | 6 * |
7 ******************************************************************************* | 7 ******************************************************************************* |
8 * file name: idnatest.c | 8 * file name: idnatest.c |
9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
11 * indentation:4 | 11 * indentation:4 |
12 * | 12 * |
13 * created on: 2003jul11 | 13 * created on: 2003jul11 |
14 * created by: Ram Viswanadha | 14 * created by: Ram Viswanadha |
15 */ | 15 */ |
16 #include <stdlib.h> | 16 #include <stdlib.h> |
17 #include <string.h> | 17 #include <string.h> |
18 #include "unicode/utypes.h" | 18 #include "unicode/utypes.h" |
19 | 19 |
20 #if !UCONFIG_NO_IDNA | 20 #if !UCONFIG_NO_IDNA |
21 | 21 |
22 #include "unicode/ustring.h" | 22 #include "unicode/ustring.h" |
23 #include "unicode/uidna.h" | 23 #include "unicode/uidna.h" |
24 #include "cintltst.h" | 24 #include "cintltst.h" |
| 25 #include "cmemory.h" |
25 | 26 |
26 | |
27 | |
28 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) | |
29 #define MAX_DEST_SIZE 1000 | 27 #define MAX_DEST_SIZE 1000 |
30 | 28 |
31 static void TestToUnicode(void); | 29 static void TestToUnicode(void); |
32 static void TestToASCII(void); | 30 static void TestToASCII(void); |
33 static void TestIDNToUnicode(void); | 31 static void TestIDNToUnicode(void); |
34 static void TestIDNToASCII(void); | 32 static void TestIDNToASCII(void); |
35 static void TestCompare(void); | 33 static void TestCompare(void); |
36 static void TestJB4490(void); | 34 static void TestJB4490(void); |
37 static void TestJB4475(void); | 35 static void TestJB4475(void); |
38 static void TestLength(void); | 36 static void TestLength(void); |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C,
0xFE0D, 0xFE0E, | 714 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C,
0xFE0D, 0xFE0E, |
717 0xFE0F, 0xFEFF, 0x00AD, 0x034F, 0x1806, 0x180B, 0x180C,
0x180D, 0x200B, | 715 0xFE0F, 0xFEFF, 0x00AD, 0x034F, 0x1806, 0x180B, 0x180C,
0x180D, 0x200B, |
718 0x200C, 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03,
0xFE04, 0xFE05, | 716 0x200C, 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03,
0xFE04, 0xFE05, |
719 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C,
0xFE0D, 0xFE0E, | 717 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C,
0xFE0D, 0xFE0E, |
720 0xFE0F, 0xFEFF, 0x00AD, 0x034F, 0x1806, 0x180B, 0x180C,
0x180D, 0x200B, | 718 0xFE0F, 0xFEFF, 0x00AD, 0x034F, 0x1806, 0x180B, 0x180C,
0x180D, 0x200B, |
721 0x200C, 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03,
0xFE04, 0xFE05, | 719 0x200C, 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03,
0xFE04, 0xFE05, |
722 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C,
0xFE0D, 0xFE0E, | 720 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C,
0xFE0D, 0xFE0E, |
723 0xFE0F, 0xFEFF, 0x0000 | 721 0xFE0F, 0xFEFF, 0x0000 |
724 }; | 722 }; |
725 | 723 |
726 int32_t len1 = LENGTHOF(ul1)-1/*remove the null termination*/; | 724 int32_t len1 = UPRV_LENGTHOF(ul1)-1/*remove the null termination*/; |
727 int32_t destLen = LENGTHOF(dest); | 725 int32_t destLen = UPRV_LENGTHOF(dest); |
728 UErrorCode status = U_ZERO_ERROR; | 726 UErrorCode status = U_ZERO_ERROR; |
729 UParseError ps; | 727 UParseError ps; |
730 int32_t len = (int32_t)strlen(cl); | 728 int32_t len = (int32_t)strlen(cl); |
731 u_charsToUChars(cl, ul, len+1); | 729 u_charsToUChars(cl, ul, len+1); |
732 destLen = uidna_toUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &s
tatus); | 730 destLen = uidna_toUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &s
tatus); |
733 if(status != U_ZERO_ERROR){ | 731 if(status != U_ZERO_ERROR){ |
734 log_err_status(status, "uidna_toUnicode failed with error %s.\n", u_
errorName(status)); | 732 log_err_status(status, "uidna_toUnicode failed with error %s.\n", u_
errorName(status)); |
735 } | 733 } |
736 | 734 |
737 status = U_ZERO_ERROR; | 735 status = U_ZERO_ERROR; |
738 destLen = LENGTHOF(dest); | 736 destLen = UPRV_LENGTHOF(dest); |
739 len = -1; | 737 len = -1; |
740 destLen = uidna_toUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &s
tatus); | 738 destLen = uidna_toUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &s
tatus); |
741 if(status != U_ZERO_ERROR){ | 739 if(status != U_ZERO_ERROR){ |
742 log_err_status(status, "uidna_toUnicode failed with error %s.\n", u_
errorName(status)); | 740 log_err_status(status, "uidna_toUnicode failed with error %s.\n", u_
errorName(status)); |
743 } | 741 } |
744 status = U_ZERO_ERROR; | 742 status = U_ZERO_ERROR; |
745 destLen = LENGTHOF(dest); | 743 destLen = UPRV_LENGTHOF(dest); |
746 len = (int32_t)strlen(cl); | 744 len = (int32_t)strlen(cl); |
747 destLen = uidna_toASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &sta
tus); | 745 destLen = uidna_toASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &sta
tus); |
748 if(status != U_IDNA_LABEL_TOO_LONG_ERROR){ | 746 if(status != U_IDNA_LABEL_TOO_LONG_ERROR){ |
749 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_er
rorName(status)); | 747 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_er
rorName(status)); |
750 } | 748 } |
751 | 749 |
752 status = U_ZERO_ERROR; | 750 status = U_ZERO_ERROR; |
753 destLen = LENGTHOF(dest); | 751 destLen = UPRV_LENGTHOF(dest); |
754 len = -1; | 752 len = -1; |
755 destLen = uidna_toASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &sta
tus); | 753 destLen = uidna_toASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &sta
tus); |
756 if(status != U_IDNA_LABEL_TOO_LONG_ERROR){ | 754 if(status != U_IDNA_LABEL_TOO_LONG_ERROR){ |
757 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_er
rorName(status)); | 755 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_er
rorName(status)); |
758 } | 756 } |
759 | 757 |
760 status = U_ZERO_ERROR; | 758 status = U_ZERO_ERROR; |
761 destLen = LENGTHOF(dest); | 759 destLen = UPRV_LENGTHOF(dest); |
762 destLen = uidna_toASCII(ul1, len1, dest, destLen, UIDNA_DEFAULT, &ps, &s
tatus); | 760 destLen = uidna_toASCII(ul1, len1, dest, destLen, UIDNA_DEFAULT, &ps, &s
tatus); |
763 if(status != U_ZERO_ERROR){ | 761 if(status != U_ZERO_ERROR){ |
764 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_er
rorName(status)); | 762 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_er
rorName(status)); |
765 } | 763 } |
766 | 764 |
767 status = U_ZERO_ERROR; | 765 status = U_ZERO_ERROR; |
768 destLen = LENGTHOF(dest); | 766 destLen = UPRV_LENGTHOF(dest); |
769 len1 = -1; | 767 len1 = -1; |
770 destLen = uidna_toASCII(ul1, len1, dest, destLen, UIDNA_DEFAULT, &ps, &s
tatus); | 768 destLen = uidna_toASCII(ul1, len1, dest, destLen, UIDNA_DEFAULT, &ps, &s
tatus); |
771 if(status != U_ZERO_ERROR){ | 769 if(status != U_ZERO_ERROR){ |
772 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_er
rorName(status)); | 770 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_er
rorName(status)); |
773 } | 771 } |
774 } | 772 } |
775 { | 773 { |
776 static const char* cl = "my_very_very_long_and_incredibly_uncreative_dom
ain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_
long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_unc
reative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my
_very_very_long_and_incredibly_uncreative_domain_label.ibm.com"; | 774 static const char* cl = "my_very_very_long_and_incredibly_uncreative_dom
ain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_
long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_unc
reative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my
_very_very_long_and_incredibly_uncreative_domain_label.ibm.com"; |
777 UChar ul[400] = {'\0'}; | 775 UChar ul[400] = {'\0'}; |
778 UChar dest[400] = {'\0'}; | 776 UChar dest[400] = {'\0'}; |
779 int32_t destLen = LENGTHOF(dest); | 777 int32_t destLen = UPRV_LENGTHOF(dest); |
780 UErrorCode status = U_ZERO_ERROR; | 778 UErrorCode status = U_ZERO_ERROR; |
781 UParseError ps; | 779 UParseError ps; |
782 int32_t len = (int32_t)strlen(cl); | 780 int32_t len = (int32_t)strlen(cl); |
783 u_charsToUChars(cl, ul, len+1); | 781 u_charsToUChars(cl, ul, len+1); |
784 | 782 |
785 destLen = uidna_IDNToUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps,
&status); | 783 destLen = uidna_IDNToUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps,
&status); |
786 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){ | 784 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){ |
787 log_err_status(status, "uidna_IDNToUnicode failed with error %s.\n",
u_errorName(status)); | 785 log_err_status(status, "uidna_IDNToUnicode failed with error %s.\n",
u_errorName(status)); |
788 } | 786 } |
789 | 787 |
790 status = U_ZERO_ERROR; | 788 status = U_ZERO_ERROR; |
791 destLen = LENGTHOF(dest); | 789 destLen = UPRV_LENGTHOF(dest); |
792 len = -1; | 790 len = -1; |
793 destLen = uidna_IDNToUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps,
&status); | 791 destLen = uidna_IDNToUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps,
&status); |
794 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){ | 792 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){ |
795 log_err_status(status, "uidna_IDNToUnicode failed with error %s.\n",
u_errorName(status)); | 793 log_err_status(status, "uidna_IDNToUnicode failed with error %s.\n",
u_errorName(status)); |
796 } | 794 } |
797 | 795 |
798 status = U_ZERO_ERROR; | 796 status = U_ZERO_ERROR; |
799 destLen = LENGTHOF(dest); | 797 destLen = UPRV_LENGTHOF(dest); |
800 len = (int32_t)strlen(cl); | 798 len = (int32_t)strlen(cl); |
801 destLen = uidna_IDNToASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &
status); | 799 destLen = uidna_IDNToASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &
status); |
802 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){ | 800 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){ |
803 log_err_status(status, "uidna_IDNToASCII failed with error %s.\n", u
_errorName(status)); | 801 log_err_status(status, "uidna_IDNToASCII failed with error %s.\n", u
_errorName(status)); |
804 } | 802 } |
805 | 803 |
806 status = U_ZERO_ERROR; | 804 status = U_ZERO_ERROR; |
807 destLen = LENGTHOF(dest); | 805 destLen = UPRV_LENGTHOF(dest); |
808 len = -1; | 806 len = -1; |
809 destLen = uidna_IDNToASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &
status); | 807 destLen = uidna_IDNToASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &
status); |
810 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){ | 808 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){ |
811 log_err_status(status, "uidna_IDNToASCII failed with error %s.\n", u
_errorName(status)); | 809 log_err_status(status, "uidna_IDNToASCII failed with error %s.\n", u
_errorName(status)); |
812 } | 810 } |
813 | 811 |
814 status = U_ZERO_ERROR; | 812 status = U_ZERO_ERROR; |
815 uidna_compare(ul, len, ul, len, UIDNA_DEFAULT, &status); | 813 uidna_compare(ul, len, ul, len, UIDNA_DEFAULT, &status); |
816 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){ | 814 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){ |
817 log_err_status(status, "uidna_compare failed with error %s.\n", u_er
rorName(status)); | 815 log_err_status(status, "uidna_compare failed with error %s.\n", u_er
rorName(status)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 UErrorCode errorCode = U_ZERO_ERROR; | 872 UErrorCode errorCode = U_ZERO_ERROR; |
875 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES|UIDNA_NONTRANSITIONAL_TO
_UNICODE, | 873 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES|UIDNA_NONTRANSITIONAL_TO
_UNICODE, |
876 &errorCode); | 874 &errorCode); |
877 if(U_FAILURE(errorCode)) { | 875 if(U_FAILURE(errorCode)) { |
878 log_err_status(errorCode, "uidna_openUTS46() failed: %s\n", u_errorName(
errorCode)); | 876 log_err_status(errorCode, "uidna_openUTS46() failed: %s\n", u_errorName(
errorCode)); |
879 return; | 877 return; |
880 } | 878 } |
881 | 879 |
882 /* These calls should succeed. */ | 880 /* These calls should succeed. */ |
883 length = uidna_labelToASCII(uts46, fA_sharps16, -1, | 881 length = uidna_labelToASCII(uts46, fA_sharps16, -1, |
884 dest16, LENGTHOF(dest16), &info, &errorCode); | 882 dest16, UPRV_LENGTHOF(dest16), &info, &errorCode
); |
885 if( U_FAILURE(errorCode) || length != 4 || 0 != u_memcmp(dest16, fass16, 5)
|| | 883 if( U_FAILURE(errorCode) || length != 4 || 0 != u_memcmp(dest16, fass16, 5)
|| |
886 !info.isTransitionalDifferent || info.errors != 0 | 884 !info.isTransitionalDifferent || info.errors != 0 |
887 ) { | 885 ) { |
888 log_err("uidna_labelToASCII() failed: %s\n", u_errorName(errorCode)); | 886 log_err("uidna_labelToASCII() failed: %s\n", u_errorName(errorCode)); |
889 } | 887 } |
890 errorCode = U_ZERO_ERROR; | 888 errorCode = U_ZERO_ERROR; |
891 length = uidna_labelToUnicode(uts46, fA_sharps16, u_strlen(fA_sharps16), | 889 length = uidna_labelToUnicode(uts46, fA_sharps16, u_strlen(fA_sharps16), |
892 dest16, LENGTHOF(dest16), &info, &errorCode); | 890 dest16, UPRV_LENGTHOF(dest16), &info, &errorCo
de); |
893 if( U_FAILURE(errorCode) || length != 3 || 0 != u_memcmp(dest16, fa_sharps16
, 4) || | 891 if( U_FAILURE(errorCode) || length != 3 || 0 != u_memcmp(dest16, fa_sharps16
, 4) || |
894 !info.isTransitionalDifferent || info.errors != 0 | 892 !info.isTransitionalDifferent || info.errors != 0 |
895 ) { | 893 ) { |
896 log_err("uidna_labelToUnicode() failed: %s\n", u_errorName(errorCode)); | 894 log_err("uidna_labelToUnicode() failed: %s\n", u_errorName(errorCode)); |
897 } | 895 } |
898 errorCode = U_ZERO_ERROR; | 896 errorCode = U_ZERO_ERROR; |
899 length = uidna_nameToASCII(uts46, fA_sharps16, u_strlen(fA_sharps16), | 897 length = uidna_nameToASCII(uts46, fA_sharps16, u_strlen(fA_sharps16), |
900 dest16, 4, &info, &errorCode); | 898 dest16, 4, &info, &errorCode); |
901 if( errorCode != U_STRING_NOT_TERMINATED_WARNING || | 899 if( errorCode != U_STRING_NOT_TERMINATED_WARNING || |
902 length != 4 || 0 != u_memcmp(dest16, fass16, 4) || | 900 length != 4 || 0 != u_memcmp(dest16, fass16, 4) || |
903 !info.isTransitionalDifferent || info.errors != 0 | 901 !info.isTransitionalDifferent || info.errors != 0 |
904 ) { | 902 ) { |
905 log_err("uidna_nameToASCII() failed: %s\n", u_errorName(errorCode)); | 903 log_err("uidna_nameToASCII() failed: %s\n", u_errorName(errorCode)); |
906 } | 904 } |
907 errorCode = U_ZERO_ERROR; | 905 errorCode = U_ZERO_ERROR; |
908 length = uidna_nameToUnicode(uts46, fA_sharps16, -1, | 906 length = uidna_nameToUnicode(uts46, fA_sharps16, -1, |
909 dest16, 3, &info, &errorCode); | 907 dest16, 3, &info, &errorCode); |
910 if( errorCode != U_STRING_NOT_TERMINATED_WARNING || | 908 if( errorCode != U_STRING_NOT_TERMINATED_WARNING || |
911 length != 3 || 0 != u_memcmp(dest16, fa_sharps16, 3) || | 909 length != 3 || 0 != u_memcmp(dest16, fa_sharps16, 3) || |
912 !info.isTransitionalDifferent || info.errors != 0 | 910 !info.isTransitionalDifferent || info.errors != 0 |
913 ) { | 911 ) { |
914 log_err("uidna_nameToUnicode() failed: %s\n", u_errorName(errorCode)); | 912 log_err("uidna_nameToUnicode() failed: %s\n", u_errorName(errorCode)); |
915 } | 913 } |
916 | 914 |
917 errorCode = U_ZERO_ERROR; | 915 errorCode = U_ZERO_ERROR; |
918 length = uidna_labelToASCII_UTF8(uts46, fA_sharps8, -1, | 916 length = uidna_labelToASCII_UTF8(uts46, fA_sharps8, -1, |
919 dest8, LENGTHOF(dest8), &info, &errorCode); | 917 dest8, UPRV_LENGTHOF(dest8), &info, &errorC
ode); |
920 if( U_FAILURE(errorCode) || length != 4 || 0 != memcmp(dest8, fass8, 5) || | 918 if( U_FAILURE(errorCode) || length != 4 || 0 != memcmp(dest8, fass8, 5) || |
921 !info.isTransitionalDifferent || info.errors != 0 | 919 !info.isTransitionalDifferent || info.errors != 0 |
922 ) { | 920 ) { |
923 log_err("uidna_labelToASCII_UTF8() failed: %s\n", u_errorName(errorCode)
); | 921 log_err("uidna_labelToASCII_UTF8() failed: %s\n", u_errorName(errorCode)
); |
924 } | 922 } |
925 errorCode = U_ZERO_ERROR; | 923 errorCode = U_ZERO_ERROR; |
926 length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, strlen(fA_sharps8), | 924 length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, strlen(fA_sharps8), |
927 dest8, LENGTHOF(dest8), &info, &errorCode)
; | 925 dest8, UPRV_LENGTHOF(dest8), &info, &error
Code); |
928 if( U_FAILURE(errorCode) || length != 4 || 0 != memcmp(dest8, fa_sharps8, 5)
|| | 926 if( U_FAILURE(errorCode) || length != 4 || 0 != memcmp(dest8, fa_sharps8, 5)
|| |
929 !info.isTransitionalDifferent || info.errors != 0 | 927 !info.isTransitionalDifferent || info.errors != 0 |
930 ) { | 928 ) { |
931 log_err("uidna_labelToUnicodeUTF8() failed: %s\n", u_errorName(errorCode
)); | 929 log_err("uidna_labelToUnicodeUTF8() failed: %s\n", u_errorName(errorCode
)); |
932 } | 930 } |
933 errorCode = U_ZERO_ERROR; | 931 errorCode = U_ZERO_ERROR; |
934 length = uidna_nameToASCII_UTF8(uts46, fA_sharps8, strlen(fA_sharps8), | 932 length = uidna_nameToASCII_UTF8(uts46, fA_sharps8, strlen(fA_sharps8), |
935 dest8, 4, &info, &errorCode); | 933 dest8, 4, &info, &errorCode); |
936 if( errorCode != U_STRING_NOT_TERMINATED_WARNING || | 934 if( errorCode != U_STRING_NOT_TERMINATED_WARNING || |
937 length != 4 || 0 != memcmp(dest8, fass8, 4) || | 935 length != 4 || 0 != memcmp(dest8, fass8, 4) || |
(...skipping 26 matching lines...) Expand all Loading... |
964 if( errorCode != U_STRING_NOT_TERMINATED_WARNING || | 962 if( errorCode != U_STRING_NOT_TERMINATED_WARNING || |
965 length != 3 || 0 != u_memcmp(dest16, fa_FFFD, 3) || | 963 length != 3 || 0 != u_memcmp(dest16, fa_FFFD, 3) || |
966 info.isTransitionalDifferent || info.errors == 0 | 964 info.isTransitionalDifferent || info.errors == 0 |
967 ) { | 965 ) { |
968 log_err("uidna_nameToUnicode(fa<BEL>) failed: %s\n", u_errorName(errorCo
de)); | 966 log_err("uidna_nameToUnicode(fa<BEL>) failed: %s\n", u_errorName(errorCo
de)); |
969 } | 967 } |
970 | 968 |
971 /* These calls should fail. */ | 969 /* These calls should fail. */ |
972 errorCode = U_USELESS_COLLATOR_ERROR; | 970 errorCode = U_USELESS_COLLATOR_ERROR; |
973 length = uidna_labelToASCII(uts46, fA_sharps16, -1, | 971 length = uidna_labelToASCII(uts46, fA_sharps16, -1, |
974 dest16, LENGTHOF(dest16), &info, &errorCode); | 972 dest16, UPRV_LENGTHOF(dest16), &info, &errorCode
); |
975 if(errorCode != U_USELESS_COLLATOR_ERROR) { | 973 if(errorCode != U_USELESS_COLLATOR_ERROR) { |
976 log_err("uidna_labelToASCII(failure) failed: %s\n", u_errorName(errorCod
e)); | 974 log_err("uidna_labelToASCII(failure) failed: %s\n", u_errorName(errorCod
e)); |
977 } | 975 } |
978 errorCode = U_ZERO_ERROR; | 976 errorCode = U_ZERO_ERROR; |
979 length = uidna_labelToUnicode(uts46, fA_sharps16, u_strlen(fA_sharps16), | 977 length = uidna_labelToUnicode(uts46, fA_sharps16, u_strlen(fA_sharps16), |
980 dest16, LENGTHOF(dest16), NULL, &errorCode); | 978 dest16, UPRV_LENGTHOF(dest16), NULL, &errorCod
e); |
981 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) { | 979 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) { |
982 log_err("uidna_labelToUnicode(UIDNAInfo=NULL) failed: %s\n", u_errorName
(errorCode)); | 980 log_err("uidna_labelToUnicode(UIDNAInfo=NULL) failed: %s\n", u_errorName
(errorCode)); |
983 } | 981 } |
984 errorCode = U_ZERO_ERROR; | 982 errorCode = U_ZERO_ERROR; |
985 length = uidna_nameToASCII(uts46, NULL, u_strlen(fA_sharps16), | 983 length = uidna_nameToASCII(uts46, NULL, u_strlen(fA_sharps16), |
986 dest16, 4, &info, &errorCode); | 984 dest16, 4, &info, &errorCode); |
987 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) { | 985 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) { |
988 log_err("uidna_nameToASCII(src=NULL) failed: %s\n", u_errorName(errorCod
e)); | 986 log_err("uidna_nameToASCII(src=NULL) failed: %s\n", u_errorName(errorCod
e)); |
989 } | 987 } |
990 errorCode = U_ZERO_ERROR; | 988 errorCode = U_ZERO_ERROR; |
991 length = uidna_nameToUnicode(uts46, fA_sharps16, -2, | 989 length = uidna_nameToUnicode(uts46, fA_sharps16, -2, |
992 dest16, 3, &info, &errorCode); | 990 dest16, 3, &info, &errorCode); |
993 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) { | 991 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) { |
994 log_err("uidna_nameToUnicode(length<-1) failed: %s\n", u_errorName(error
Code)); | 992 log_err("uidna_nameToUnicode(length<-1) failed: %s\n", u_errorName(error
Code)); |
995 } | 993 } |
996 | 994 |
997 errorCode = U_ZERO_ERROR; | 995 errorCode = U_ZERO_ERROR; |
998 length = uidna_labelToASCII_UTF8(uts46, fA_sharps8, -1, | 996 length = uidna_labelToASCII_UTF8(uts46, fA_sharps8, -1, |
999 NULL, LENGTHOF(dest8), &info, &errorCode); | 997 NULL, UPRV_LENGTHOF(dest8), &info, &errorCo
de); |
1000 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) { | 998 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) { |
1001 log_err("uidna_labelToASCII_UTF8(dest=NULL) failed: %s\n", u_errorName(e
rrorCode)); | 999 log_err("uidna_labelToASCII_UTF8(dest=NULL) failed: %s\n", u_errorName(e
rrorCode)); |
1002 } | 1000 } |
1003 errorCode = U_ZERO_ERROR; | 1001 errorCode = U_ZERO_ERROR; |
1004 length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, strlen(fA_sharps8), | 1002 length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, strlen(fA_sharps8), |
1005 dest8, -1, &info, &errorCode); | 1003 dest8, -1, &info, &errorCode); |
1006 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) { | 1004 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) { |
1007 log_err("uidna_labelToUnicodeUTF8(capacity<0) failed: %s\n", u_errorName
(errorCode)); | 1005 log_err("uidna_labelToUnicodeUTF8(capacity<0) failed: %s\n", u_errorName
(errorCode)); |
1008 } | 1006 } |
1009 errorCode = U_ZERO_ERROR; | 1007 errorCode = U_ZERO_ERROR; |
(...skipping 15 matching lines...) Expand all Loading... |
1025 #endif | 1023 #endif |
1026 | 1024 |
1027 /* | 1025 /* |
1028 * Hey, Emacs, please set the following: | 1026 * Hey, Emacs, please set the following: |
1029 * | 1027 * |
1030 * Local Variables: | 1028 * Local Variables: |
1031 * indent-tabs-mode: nil | 1029 * indent-tabs-mode: nil |
1032 * End: | 1030 * End: |
1033 * | 1031 * |
1034 */ | 1032 */ |
OLD | NEW |