]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/cintltst/nccbtst.c
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / test / cintltst / nccbtst.c
index f4e3c37d71f72ead0b9315d27ae4d1113ac6379c..c15ac6dd196d0b9eef78f322cbff55d6d5fbb8e2 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2011, International Business Machines Corporation and
+ * Copyright (c) 1997-2013, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /*
  * others. All Rights Reserved.
  ********************************************************************/
 /*
@@ -426,7 +426,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
             log_err("u-> ibm-943 with skip did not match.\n");
 
         if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
             log_err("u-> ibm-943 with skip did not match.\n");
 
         if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
-                to_euc_jp, sizeof(to_euc_jp), "euc-jp",
+                to_euc_jp, sizeof(to_euc_jp), "IBM-eucJP",
                 UCNV_FROM_U_CALLBACK_SKIP, fromEUC_JPOffs, NULL, 0 ))
             log_err("u-> euc-jp with skip did not match.\n");
 
                 UCNV_FROM_U_CALLBACK_SKIP, fromEUC_JPOffs, NULL, 0 ))
             log_err("u-> euc-jp with skip did not match.\n");
 
@@ -765,8 +765,8 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
                 /*iso-2022-jp*/
         static const uint8_t sampleTxt_iso_2022_jp[]={ 
             0x41,
                 /*iso-2022-jp*/
         static const uint8_t sampleTxt_iso_2022_jp[]={ 
             0x41,
-            0x1b,   0x24,   0x42,   0x2A, 0x44, /*unassigned*/
-             0x1b,   0x28,   0x42,   0x42,
+            0x1b,   0x24,   0x42,   0x3a, 0x1a, /*unassigned*/
+            0x1b,   0x28,   0x42,   0x42,
             
         };
         static const UChar iso_2022_jptoUnicode[]={    0x41,0x42 };
             
         };
         static const UChar iso_2022_jptoUnicode[]={    0x41,0x42 };
@@ -857,7 +857,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
         log_err("EBCIDIC_STATEFUL->u with skip did not match.\n");
 
         if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
         log_err("EBCIDIC_STATEFUL->u with skip did not match.\n");
 
         if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
-                 euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp",
+                 euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"IBM-eucJP",
                 UCNV_TO_U_CALLBACK_SKIP, from_euc_jpOffs , NULL, 0))
             log_err("euc-jp->u with skip did not match.\n");
 
                 UCNV_TO_U_CALLBACK_SKIP, from_euc_jpOffs , NULL, 0))
             log_err("euc-jp->u with skip did not match.\n");
 
@@ -1195,7 +1195,7 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
             log_err("u-> ibm-943 with stop did not match.\n");
 
         if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
             log_err("u-> ibm-943 with stop did not match.\n");
 
         if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
-                to_euc_jp, sizeof(to_euc_jp), "euc-jp",
+                to_euc_jp, sizeof(to_euc_jp), "IBM-eucJP",
                 UCNV_FROM_U_CALLBACK_STOP, fromEUC_JPOffs, NULL, 0 ))
             log_err("u-> euc-jp with stop did not match.\n");
 
                 UCNV_FROM_U_CALLBACK_STOP, fromEUC_JPOffs, NULL, 0 ))
             log_err("u-> euc-jp with stop did not match.\n");
 
@@ -1307,7 +1307,7 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
         log_err("EBCIDIC_STATEFUL->u with stop did not match.\n");
 
         if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
         log_err("EBCIDIC_STATEFUL->u with stop did not match.\n");
 
         if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
-             euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp",
+             euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"IBM-eucJP",
             UCNV_TO_U_CALLBACK_STOP, from_euc_jpOffs , NULL, 0))
         log_err("euc-jp->u with stop did not match.\n");
 
             UCNV_TO_U_CALLBACK_STOP, from_euc_jpOffs , NULL, 0))
         log_err("euc-jp->u with stop did not match.\n");
 
@@ -1420,7 +1420,7 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
             log_err("u-> ibm-943 with substitute did not match.\n");
 
         if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
             log_err("u-> ibm-943 with substitute did not match.\n");
 
         if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
-                to_euc_jp, sizeof(to_euc_jp), "euc-jp",
+                to_euc_jp, sizeof(to_euc_jp), "IBM-eucJP",
                 UCNV_FROM_U_CALLBACK_SUBSTITUTE, fromEUC_JPOffs, NULL, 0 ))
             log_err("u-> euc-jp with substitute did not match.\n");
 
                 UCNV_FROM_U_CALLBACK_SUBSTITUTE, fromEUC_JPOffs, NULL, 0 ))
             log_err("u-> euc-jp with substitute did not match.\n");
 
@@ -1590,7 +1590,7 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
 
 
         if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
 
 
         if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
-           euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp",
+           euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"IBM-eucJP",
           UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_jpOffs, NULL, 0 ))
             log_err("euc-jp->u with substitute did not match.\n");
 
           UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_jpOffs, NULL, 0 ))
             log_err("euc-jp->u with substitute did not match.\n");
 
@@ -1602,7 +1602,7 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
 
         
         if(!testConvertToUnicodeWithContext(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
 
         
         if(!testConvertToUnicodeWithContext(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
-           euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp",
+           euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"IBM-eucJP",
           UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_jpOffs, NULL, 0 ,"i", U_ILLEGAL_CHAR_FOUND))
             log_err("euc-jp->u with substitute did not match.\n");
     }
           UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_jpOffs, NULL, 0 ,"i", U_ILLEGAL_CHAR_FOUND))
             log_err("euc-jp->u with substitute did not match.\n");
     }
@@ -2051,7 +2051,7 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
             log_err("u-> ibm-943 with subst with value did not match.\n");
 
         if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
             log_err("u-> ibm-943 with subst with value did not match.\n");
 
         if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
-                to_euc_jp, sizeof(to_euc_jp), "euc-jp",
+                to_euc_jp, sizeof(to_euc_jp), "IBM-eucJP",
                 UCNV_FROM_U_CALLBACK_ESCAPE, fromEUC_JPOffs, NULL, 0 ))
             log_err("u-> euc-jp with subst with value did not match.\n");
 
                 UCNV_FROM_U_CALLBACK_ESCAPE, fromEUC_JPOffs, NULL, 0 ))
             log_err("u-> euc-jp with subst with value did not match.\n");
 
@@ -2314,13 +2314,14 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
         /*iso-2022-jp*/
         static const uint8_t sampleTxt_iso_2022_jp[]={ 
             0x1b,   0x28,   0x42,   0x41,
         /*iso-2022-jp*/
         static const uint8_t sampleTxt_iso_2022_jp[]={ 
             0x1b,   0x28,   0x42,   0x41,
-            0x1b,   0x24,   0x42,   0x2A, 0x44, /*unassigned*/
+            0x1b,   0x24,   0x42,   0x3a, 0x1a, /*unassigned*/
             0x1b,   0x28,   0x42,   0x42,
             
         };
             0x1b,   0x28,   0x42,   0x42,
             
         };
-        static const UChar iso_2022_jptoUnicode[]={    0x41,0x25,0x58,0x32,0x41,0x25,0x58,0x34,0x34, 0x42 };
+                                                   /*     A    %    X    3    A    %    X    1    A     B    */
+        static const UChar iso_2022_jptoUnicode[]={    0x41,0x25,0x58,0x33,0x41,0x25,0x58,0x31,0x41, 0x42 };
         static const int32_t from_iso_2022_jpOffs [] ={  3,   7,   7,   7,   7,   7,   7,   7,   7,    12   };
         static const int32_t from_iso_2022_jpOffs [] ={  3,   7,   7,   7,   7,   7,   7,   7,   7,    12   };
-        
+
         /*iso-2022-cn*/
         static const uint8_t sampleTxt_iso_2022_cn[]={ 
             0x0f,   0x41,   0x44,
         /*iso-2022-cn*/
         static const uint8_t sampleTxt_iso_2022_cn[]={ 
             0x0f,   0x41,   0x44,
@@ -2434,7 +2435,7 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
             log_err("ibm-943->u with substitute with value did not match.\n");
 
         if(!testConvertToUnicode(sampleTxt_EUC_JP, sizeof(sampleTxt_EUC_JP),
             log_err("ibm-943->u with substitute with value did not match.\n");
 
         if(!testConvertToUnicode(sampleTxt_EUC_JP, sizeof(sampleTxt_EUC_JP),
-                 EUC_JPtoUnicode, sizeof(EUC_JPtoUnicode)/sizeof(EUC_JPtoUnicode[0]),"euc-jp",
+                 EUC_JPtoUnicode, sizeof(EUC_JPtoUnicode)/sizeof(EUC_JPtoUnicode[0]),"IBM-eucJP",
                 UCNV_TO_U_CALLBACK_ESCAPE, fromEUC_JPOffs, NULL, 0))
             log_err("euc-jp->u with substitute with value did not match.\n");
 
                 UCNV_TO_U_CALLBACK_ESCAPE, fromEUC_JPOffs, NULL, 0))
             log_err("euc-jp->u with substitute with value did not match.\n");
 
@@ -2457,8 +2458,9 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
             {
                 static const UChar iso_2022_jptoUnicodeDec[]={
                                                   0x0041,   
             {
                 static const UChar iso_2022_jptoUnicodeDec[]={
                                                   0x0041,   
-                                                  0x0026,   0x0023,   0x0034,   0x0032,   0x003b,   
-                                                  0x0026,   0x0023,   0x0036,   0x0038,   0x003b,   
+                                                  /*   &         #         5         8         ;   */
+                                                  0x0026,   0x0023,   0x0035,   0x0038,   0x003b,   
+                                                  0x0026,   0x0023,   0x0032,   0x0036,   0x003b,   
                                                   0x0042 };
                 static const int32_t from_iso_2022_jpOffsDec [] ={ 3,7,7,7,7,7,7,7,7,7,7,12,  };
                 if(!testConvertToUnicodeWithContext(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
                                                   0x0042 };
                 static const int32_t from_iso_2022_jpOffsDec [] ={ 3,7,7,7,7,7,7,7,7,7,7,12,  };
                 if(!testConvertToUnicodeWithContext(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
@@ -2469,8 +2471,9 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
             {
                 static const UChar iso_2022_jptoUnicodeHex[]={
                                                   0x0041, 
             {
                 static const UChar iso_2022_jptoUnicodeHex[]={
                                                   0x0041, 
-                                                  0x0026, 0x0023, 0x0078, 0x0032, 0x0041, 0x003b, 
-                                                  0x0026, 0x0023, 0x0078, 0x0034, 0x0034, 0x003b, 
+                                                  /*   &       #       x       3       A       ;  */
+                                                  0x0026, 0x0023, 0x0078, 0x0033, 0x0041, 0x003b, 
+                                                  0x0026, 0x0023, 0x0078, 0x0031, 0x0041, 0x003b, 
                                                   0x0042 };
                 static const int32_t from_iso_2022_jpOffsHex [] ={  3,7,7,7,7,7,7,7,7,7,7,7,7,12   };
                 if(!testConvertToUnicodeWithContext(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
                                                   0x0042 };
                 static const int32_t from_iso_2022_jpOffsHex [] ={  3,7,7,7,7,7,7,7,7,7,7,7,7,12   };
                 if(!testConvertToUnicodeWithContext(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
@@ -2481,8 +2484,8 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
             {
                 static const UChar iso_2022_jptoUnicodeC[]={
                                                 0x0041, 
             {
                 static const UChar iso_2022_jptoUnicodeC[]={
                                                 0x0041, 
-                                                0x005C, 0x0078, 0x0032, 0x0041,
-                                                0x005C, 0x0078, 0x0034, 0x0034, 
+                                                0x005C, 0x0078, 0x0033, 0x0041,   /*  \x3A */
+                                                0x005C, 0x0078, 0x0031, 0x0041,   /*  \x1A */
                                                 0x0042 };
                 int32_t from_iso_2022_jpOffsC [] ={  3,7,7,7,7,7,7,7,7,12   };
                 if(!testConvertToUnicodeWithContext(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
                                                 0x0042 };
                 int32_t from_iso_2022_jpOffsC [] ={  3,7,7,7,7,7,7,7,7,12   };
                 if(!testConvertToUnicodeWithContext(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
@@ -2721,14 +2724,11 @@ UBool testConvertFromUnicode(const UChar *source, int sourceLen,  const uint8_t
         UChar errChars[50]; /* should be sufficient */
         int8_t errLen = 50;
         UErrorCode err = U_ZERO_ERROR;
         UChar errChars[50]; /* should be sufficient */
         int8_t errLen = 50;
         UErrorCode err = U_ZERO_ERROR;
-        const UChar* limit= NULL;
         const UChar* start= NULL;
         ucnv_getInvalidUChars(conv,errChars, &errLen, &err);
         if(U_FAILURE(err)){
             log_err("ucnv_getInvalidUChars failed with error : %s\n",u_errorName(err));
         }
         const UChar* start= NULL;
         ucnv_getInvalidUChars(conv,errChars, &errLen, &err);
         if(U_FAILURE(err)){
             log_err("ucnv_getInvalidUChars failed with error : %s\n",u_errorName(err));
         }
-        /* src points to limit of invalid chars */
-        limit = src;
         /* length of in invalid chars should be equal to returned length*/
         start = src - errLen;
         if(u_strncmp(errChars,start,errLen)!=0){
         /* length of in invalid chars should be equal to returned length*/
         start = src - errLen;
         if(u_strncmp(errChars,start,errLen)!=0){
@@ -2919,14 +2919,11 @@ UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const UChar *e
         char errChars[50]; /* should be sufficient */
         int8_t errLen = 50;
         UErrorCode err = U_ZERO_ERROR;
         char errChars[50]; /* should be sufficient */
         int8_t errLen = 50;
         UErrorCode err = U_ZERO_ERROR;
-        const char* limit= NULL;
         const char* start= NULL;
         ucnv_getInvalidChars(conv,errChars, &errLen, &err);
         if(U_FAILURE(err)){
             log_err("ucnv_getInvalidChars failed with error : %s\n",u_errorName(err));
         }
         const char* start= NULL;
         ucnv_getInvalidChars(conv,errChars, &errLen, &err);
         if(U_FAILURE(err)){
             log_err("ucnv_getInvalidChars failed with error : %s\n",u_errorName(err));
         }
-        /* src points to limit of invalid chars */
-        limit = src;
         /* length of in invalid chars should be equal to returned length*/
         start = src - errLen;
         if(uprv_strncmp(errChars,start,errLen)!=0){
         /* length of in invalid chars should be equal to returned length*/
         start = src - errLen;
         if(uprv_strncmp(errChars,start,errLen)!=0){