]> granicus.if.org Git - icu/commitdiff
ICU-8874 Fixed test case problem which triggered TestIDNAMonkeyTest failure intermitt...
authorYoshito Umaoka <y.umaoka@gmail.com>
Fri, 7 Oct 2011 22:28:32 +0000 (22:28 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Fri, 7 Oct 2011 22:28:32 +0000 (22:28 +0000)
X-SVN-Rev: 30804

icu4c/source/test/intltest/idnaref.cpp
icu4c/source/test/intltest/testidna.cpp

index eabe1f56d3a1206cd6d314c916a311903528b9d6..33f0918f24fbf789b2cdfd83f1db6cafaf486886 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 2003-2007, International Business Machines
+ *   Copyright (C) 2003-2011, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
@@ -285,31 +285,33 @@ idnaref_toASCII(const UChar* src, int32_t srcLength,
         }
         b1[b1Len++] = src[j];
     }
-    // step 2
-    NamePrepTransform* prep = TestIDNA::getInstance(*status);
 
+    NamePrepTransform* prep = TestIDNA::getInstance(*status);
     if(U_FAILURE(*status)){
         goto CLEANUP;
     }
 
-    b1Len = prep->process(src,srcLength,b1, b1Capacity,allowUnassigned,parseError,*status);
+    // step 2 is performed only if the source contains non ASCII
+    if (!srcIsASCII) {
+        b1Len = prep->process(src,srcLength,b1, b1Capacity,allowUnassigned,parseError,*status);
 
-    if(*status == U_BUFFER_OVERFLOW_ERROR){
-        // redo processing of string
-        /* we do not have enough room so grow the buffer*/
-        b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
-        if(b1==NULL){
-            *status = U_MEMORY_ALLOCATION_ERROR;
-            goto CLEANUP;
-        }
+        if(*status == U_BUFFER_OVERFLOW_ERROR){
+            // redo processing of string
+            /* we do not have enough room so grow the buffer*/
+            b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+            if(b1==NULL){
+                *status = U_MEMORY_ALLOCATION_ERROR;
+                goto CLEANUP;
+            }
 
-        *status = U_ZERO_ERROR; // reset error
+            *status = U_ZERO_ERROR; // reset error
 
-        b1Len = prep->process(src,srcLength,b1, b1Len,allowUnassigned, parseError, *status);
-    }
-    // error bail out
-    if(U_FAILURE(*status)){
-        goto CLEANUP;
+            b1Len = prep->process(src,srcLength,b1, b1Len,allowUnassigned, parseError, *status);
+        }
+        // error bail out
+        if(U_FAILURE(*status)){
+            goto CLEANUP;
+        }
     }
 
     if(b1Len == 0){
index d15cc6a4992e341c0804577d1692196aad341833..617d960311b45c62a4d9ada95062cbaeedc846e4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 2003-2010, International Business Machines
+ *   Copyright (C) 2003-2011, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
@@ -1520,23 +1520,24 @@ void TestIDNA::TestIDNAMonkeyTest(){
 }
 
 void TestIDNA::TestCompareReferenceImpl(){
-    
+
     UChar src [2] = {0,0};
     int32_t srcLen = 0;
-    
 
-    for(int32_t i = 0x40000 ; i< 0x10ffff; i++){
-        if(quick==TRUE && i> 0x1FFFF){
+
+    for (int32_t i = 0; i <= 0x10FFFF; i++){
+        if (quick == TRUE && i > 0x0FFF){
             return;
         }
-        if(i >= 0x30000 && i <= 0xF0000){
-           i+=0xB0000;
+        if(i == 0x30000){
+            // jump to E0000, no characters assigned in plain 3 to plain 13 as of Unicode 6.0
+            i = 0xE0000;
         }
-        if(i>0xFFFF){
-           src[0] = U16_LEAD(i);
-           src[1] = U16_TRAIL(i);
-           srcLen =2;
-        }else{
+        if (i > 0xFFFF){
+            src[0] = U16_LEAD(i);
+            src[1] = U16_TRAIL(i);
+            srcLen =2;
+        } else {
             src[0] = (UChar)i;
             src[1] = 0;
             srcLen = 1;