]> granicus.if.org Git - icu/commitdiff
ICU-8123 Remove utext comparison functions.
authorAndy Heninger <andy.heninger@gmail.com>
Tue, 31 Jan 2012 01:14:41 +0000 (01:14 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Tue, 31 Jan 2012 01:14:41 +0000 (01:14 +0000)
X-SVN-Rev: 31277

icu4c/source/common/unicode/utext.h
icu4c/source/common/utext.cpp
icu4c/source/test/cintltst/reapits.c
icu4c/source/test/intltest/regextst.cpp
icu4c/source/test/intltest/utxttest.cpp
icu4c/source/test/intltest/utxttest.h

index 900cfcd71166b3e9daee39d472a604ef6ab4d3ce..e5f0c8cfce18421f76ae381f505983f9400b53bd 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2004-2011, International Business Machines
+*   Copyright (C) 2004-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -675,149 +675,6 @@ utext_extract(UText *ut,
              UErrorCode *status);
 
 
-#ifndef U_HIDE_INTERNAL_API
-/**
- * Compare two UTexts (binary order). The comparison begins at each source text's
- * iteration position. The iteration position of each UText will be left following
- * the last character compared.
- *
- * The comparison is done in code point order; unlike u_strCompare, you
- * cannot choose to use code unit order. This is because the characters
- * in a UText are accessed one code point at a time, and may not be from a UTF-16
- * context.
- *
- * This functions works with strings of different explicitly specified lengths
- * unlike the ANSI C-like u_strcmp() and u_memcmp() etc.
- * A length argument of -1 signifies that as much of the string should be used as
- * is necessary to compare with the other string. If both length arguments are -1,
- * the entire remaining portionss of both strings are used.
- *
- * @param s1 First source string.
- * @param length1 Length of first source string in UTF-32 code points.
- *
- * @param s2 Second source string.
- * @param length2 Length of second source string in UTF-32 code points.
- *
- * @return <0 or 0 or >0 as usual for string comparisons
- *
- * @internal ICU 4.4 technology preview
- */
-U_INTERNAL int32_t U_EXPORT2
-utext_compare(UText *s1, int32_t length1,
-              UText *s2, int32_t length2);    
-
-/**
- * Compare two UTexts (binary order). The comparison begins at each source text's
- * iteration position. The iteration position of each UText will be left following
- * the last character compared. This method differs from utext_compare in that
- * it accepts native limits rather than lengths for each string.
- *
- * The comparison is done in code point order; unlike u_strCompare, you
- * cannot choose to use code unit order. This is because the characters
- * in a UText are accessed one code point at a time, and may not be from a UTF-16
- * context.
- *
- * This functions works with strings of different explicitly specified lengths
- * unlike the ANSI C-like u_strcmp() and u_memcmp() etc.
- * A limit argument of -1 signifies that as much of the string should be used as
- * is necessary to compare with the other string. If both limit arguments are -1,
- * the entire remaining portionss of both strings are used.
- *
- * @param s1 First source string.
- * @param limit1 Native index of the last character in the first source string to be considered.
- *
- * @param s2 Second source string.
- * @param limit2 Native index of the last character in the second source string to be considered.
- *
- * @return <0 or 0 or >0 as usual for string comparisons
- *
- * @internal ICU 4.4 technology preview
- */
-U_INTERNAL int32_t U_EXPORT2
-utext_compareNativeLimit(UText *s1, int64_t limit1,
-                         UText *s2, int64_t limit2);    
-
-/**
- * Compare two UTexts case-insensitively using full case folding. The comparison
- * begins at each source text's iteration position. The iteration position of each
- * UText will be left following the last character compared.
- *
- * The comparison is done in code point order; this is because the characters
- * in a UText are accessed one code point at a time, and may not be from a UTF-16
- * context.
- *
- * This functions works with strings of different explicitly specified lengths
- * unlike the ANSI C-like u_strcmp() and u_memcmp() etc.
- * A length argument of -1 signifies that as much of the string should be used as
- * is necessary to compare with the other string. If both length arguments are -1,
- * the entire remaining portionss of both strings are used.
- *
- * @param s1 First source string.
- * @param length1 Length of first source string in UTF-32 code points.
- *
- * @param s2 Second source string.
- * @param length2 Length of second source string in UTF-32 code points.
- *
- * @param options A bit set of options:
- *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
- *     Comparison in code point order with default case folding.
- *
- *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
- *
- * @param pErrorCode Must be a valid pointer to an error code value,
- *                  which must not indicate a failure before the function call.
- *
- * @return <0 or 0 or >0 as usual for string comparisons
- *
- * @internal ICU 4.4 technology preview
- */
-U_INTERNAL int32_t U_EXPORT2
-utext_caseCompare(UText *s1, int32_t length1,
-                  UText *s2, int32_t length2,
-                  uint32_t options, UErrorCode *pErrorCode);    
-
-/**
- * Compare two UTexts case-insensitively using full case folding. The comparison
- * begins at each source text's iteration position. The iteration position of each
- * UText will be left following the last character compared. This method differs from
- * utext_caseCompare in that it accepts native limits rather than lengths for each
- * string.
- *
- * The comparison is done in code point order; this is because the characters
- * in a UText are accessed one code point at a time, and may not be from a UTF-16
- * context.
- *
- * This functions works with strings of different explicitly specified lengths
- * unlike the ANSI C-like u_strcmp() and u_memcmp() etc.
- * A limit argument of -1 signifies that as much of the string should be used as
- * is necessary to compare with the other string. If both length arguments are -1,
- * the entire remaining portionss of both strings are used.
- *
- * @param s1 First source string.
- * @param limit1 Native index of the last character in the first source string to be considered.
- *
- * @param s2 Second source string.
- * @param limit2 Native index of the last character in the second source string to be considered.
- *
- * @param options A bit set of options:
- *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
- *     Comparison in code point order with default case folding.
- *
- *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
- *
- * @param pErrorCode Must be a valid pointer to an error code value,
- *                  which must not indicate a failure before the function call.
- *
- * @return <0 or 0 or >0 as usual for string comparisons
- *
- * @internal ICU 4.4 technology preview
- */
-U_INTERNAL int32_t U_EXPORT2
-utext_caseCompareNativeLimit(UText *s1, int64_t limit1,
-                             UText *s2, int64_t limit2,
-                             uint32_t options, UErrorCode *pErrorCode);    
-#endif  /* U_HIDE_INTERNAL_API */
-
 
 /************************************************************************************
  *
index 6b98b825be91ba7271167f7bee2ffd5a3b89ad31..fc5977554dd049b4b89afdd9d2fea9e3481c0a3c 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2005-2011, International Business Machines
+*   Copyright (C) 2005-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -454,355 +454,6 @@ utext_equals(const UText *a, const UText *b) {
     return TRUE;
 }
 
-U_CAPI int32_t U_EXPORT2
-utext_compare(UText *s1, int32_t length1,
-              UText *s2, int32_t length2) {
-    UChar32 c1 = 0, c2 = 0;
-    
-    if(length1<0 && length2<0) {
-        /* strcmp style, go until end of string */
-        for(;;) {
-            c1 = UTEXT_NEXT32(s1);
-            c2 = UTEXT_NEXT32(s2);
-            if(c1 != c2) {
-                break;
-            } else if(c1 == U_SENTINEL) {
-                return 0;
-            }
-        }
-    } else {
-        if(length1 < 0) {
-            length1 = INT32_MIN;
-        } else if (length2 < 0) {
-            length2 = INT32_MIN;
-        }
-        
-        /* memcmp/UnicodeString style, both length-specified */        
-        while((length1 > 0 || length1 == INT32_MIN) && (length2 > 0 || length2 == INT32_MIN)) {
-            c1 = UTEXT_NEXT32(s1);
-            c2 = UTEXT_NEXT32(s2);
-                       
-            if(c1 != c2) {
-                break;
-            } else if(c1 == U_SENTINEL) {
-                return 0;
-            }
-            
-            if (length1 != INT32_MIN) {
-                length1 -= 1;
-            }
-            if (length2 != INT32_MIN) {
-                length2 -= 1;
-            }
-        }
-        
-        if(length1 <= 0 && length1 != INT32_MIN) {
-            if(length2 <= 0) {
-                return 0;
-            } else {
-                return -1;
-            }
-        } else if(length2 <= 0 && length2 != INT32_MIN) {
-            if (length1 <= 0) {
-                return 0;
-            } else {
-                return 1;
-            }
-        }
-    }
-    
-    return (int32_t)c1-(int32_t)c2;
-}
-
-U_CAPI int32_t U_EXPORT2
-utext_compareNativeLimit(UText *s1, int64_t limit1,
-                         UText *s2, int64_t limit2) {
-    UChar32 c1, c2;
-    
-    if(limit1<0 && limit2<0) {
-        /* strcmp style, go until end of string */
-        for(;;) {
-            c1 = UTEXT_NEXT32(s1);
-            c2 = UTEXT_NEXT32(s2);
-            if(c1 != c2) {
-                return (int32_t)c1-(int32_t)c2;
-            } else if(c1 == U_SENTINEL) {
-                return 0;
-            }
-        }
-    } else {
-        /* memcmp/UnicodeString style, both length-specified */   
-        int64_t index1 = (limit1 >= 0 ? UTEXT_GETNATIVEINDEX(s1) : 0);
-        int64_t index2 = (limit2 >= 0 ? UTEXT_GETNATIVEINDEX(s2) : 0);
-        
-        while((limit1 < 0 || index1 < limit1) && (limit2 < 0 || index2 < limit2)) {
-            c1 = UTEXT_NEXT32(s1);
-            c2 = UTEXT_NEXT32(s2);
-            
-            if(c1 != c2) {
-                return (int32_t)c1-(int32_t)c2;
-            } else if(c1 == U_SENTINEL) {
-                return 0;
-            }
-            
-            if (limit1 >= 0) {
-                index1 = UTEXT_GETNATIVEINDEX(s1);
-            }
-            if (limit2 >= 0) {
-                index2 = UTEXT_GETNATIVEINDEX(s2);
-            }
-        }
-        
-        if(limit1 >= 0 && index1 >= limit1) {
-            if(index2 >= limit2) {
-                return 0;
-            } else {
-                return -1;
-            }
-        } else {
-            if(index1 >= limit1) {
-                return 0;
-            } else {
-                return 1;
-            }
-        }
-    }
-}
-
-U_CAPI int32_t U_EXPORT2
-utext_caseCompare(UText *s1, int32_t length1,
-                     UText *s2, int32_t length2,
-                     uint32_t options, UErrorCode *pErrorCode) {
-    const UCaseProps *csp;
-    
-    /* case folding variables */
-    const UChar *p;
-    int32_t length;
-    
-    /* case folding buffers, only use current-level start/limit */
-    UChar fold1[UCASE_MAX_STRING_LENGTH+1], fold2[UCASE_MAX_STRING_LENGTH+1];
-    int32_t foldOffset1, foldOffset2, foldLength1, foldLength2;
-    
-    /* current code points */
-    UChar32 c1, c2;
-    uint8_t cLength1, cLength2;
-
-    /* argument checking */
-    if(U_FAILURE(*pErrorCode)) {
-        return 0;
-    }
-    if(s1==NULL || s2==NULL) {
-        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
-        return 0;
-    }
-
-    csp=ucase_getSingleton();
-
-    /* for variable-length strings */
-    if(length1 < 0) {
-        length1 = INT32_MIN;
-    }
-    if (length2 < 0) {
-        length2 = INT32_MIN;
-    }
-    
-    /* initialize */
-    foldOffset1 = foldOffset2 = foldLength1 = foldLength2 = 0;
-    
-    /* comparison loop */
-    while((foldOffset1 < foldLength1 || length1 > 0 || length1 == INT32_MIN) &&
-          (foldOffset2 < foldLength2 || length2 > 0 || length2 == INT32_MIN)) {
-        if(foldOffset1 < foldLength1) {
-            U16_NEXT_UNSAFE(fold1, foldOffset1, c1);
-            cLength1 = 0;
-        } else {
-            c1 = UTEXT_NEXT32(s1);
-            if (c1 != U_SENTINEL) {
-                cLength1 = U16_LENGTH(c1);
-                
-                length = ucase_toFullFolding(csp, c1, &p, options);
-                if(length >= 0) {
-                    if(length <= UCASE_MAX_STRING_LENGTH) {   // !!!: Does not correctly handle 0-length folded-case strings
-                        u_memcpy(fold1, p, length);
-                        foldOffset1 = 0;
-                        foldLength1 = length;
-                        U16_NEXT_UNSAFE(fold1, foldOffset1, c1);
-                    } else {
-                        c1 = length;
-                    }
-                }
-            }
-            
-            if(length1 != INT32_MIN) {
-                length1 -= 1;
-            }
-        }
-        
-        if(foldOffset2 < foldLength2) {
-            U16_NEXT_UNSAFE(fold2, foldOffset2, c2);
-            cLength2 = 0;
-        } else {
-            c2 = UTEXT_NEXT32(s2);
-            if (c2 != U_SENTINEL) {
-                cLength2 = U16_LENGTH(c2);
-                
-                length = ucase_toFullFolding(csp, c2, &p, options);
-                if(length >= 0) {
-                    if(length <= UCASE_MAX_STRING_LENGTH) {   // !!!: Does not correctly handle 0-length folded-case strings
-                        u_memcpy(fold2, p, length);
-                        foldOffset2 = 0;
-                        foldLength2 = length;
-                        U16_NEXT_UNSAFE(fold2, foldOffset2, c2);
-                    } else {
-                        c2 = length;
-                    }
-                }
-            } else if(c1 == U_SENTINEL) {
-                return 0; // end of both strings at once
-            }
-            
-            if(length2 != INT32_MIN) {
-                length2 -= 1;
-            }
-        }
-        
-        if(c1 != c2) {
-            return (int32_t)c1-(int32_t)c2;
-        }
-    }
-    
-    /* By now at least one of the strings is out of characters */
-    length1 += foldLength1 - foldOffset1;
-    length2 += foldLength2 - foldOffset2;
-    
-    if(length1 <= 0 && length1 != INT32_MIN) {
-        if(length2 <= 0) {
-            return 0;
-        } else {
-            return -1;
-        }
-    } else {
-        if (length1 <= 0) {
-            return 0;
-        } else {
-            return 1;
-        }
-    }
-}
-
-U_CAPI int32_t U_EXPORT2
-utext_caseCompareNativeLimit(UText *s1, int64_t limit1,
-                                UText *s2, int64_t limit2,
-                                uint32_t options, UErrorCode *pErrorCode) {
-    const UCaseProps *csp;
-    
-    /* case folding variables */
-    const UChar *p;
-    int32_t length;
-    
-    /* case folding buffers, only use current-level start/limit */
-    UChar fold1[UCASE_MAX_STRING_LENGTH+1], fold2[UCASE_MAX_STRING_LENGTH+1];
-    int32_t foldOffset1, foldOffset2, foldLength1, foldLength2;
-    
-    /* current code points */
-    UChar32 c1, c2;
-    
-    /* native indexes into s1 and s2 */
-    int64_t index1, index2;
-
-    /* argument checking */
-    if(U_FAILURE(*pErrorCode)) {
-        return 0;
-    }
-    if(s1==NULL || s2==NULL) {
-        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
-        return 0;
-    }
-
-    csp=ucase_getSingleton();
-
-    /* initialize */
-    index1 = (limit1 >= 0 ? UTEXT_GETNATIVEINDEX(s1) : 0);
-    index2 = (limit2 >= 0 ? UTEXT_GETNATIVEINDEX(s2) : 0);
-
-    foldOffset1 = foldOffset2 = foldLength1 = foldLength2 = 0;
-    
-    /* comparison loop */
-    while((foldOffset1 < foldLength1 || limit1 < 0 || index1 < limit1) &&
-          (foldOffset2 < foldLength2 || limit2 < 0 || index2 < limit2)) {
-        if(foldOffset1 < foldLength1) {
-            U16_NEXT_UNSAFE(fold1, foldOffset1, c1);
-        } else {
-            c1 = UTEXT_NEXT32(s1);
-            if (c1 != U_SENTINEL) {
-                length = ucase_toFullFolding(csp, c1, &p, options);
-                if(length >= 0) {
-                    if(length <= UCASE_MAX_STRING_LENGTH) {   // !!!: Does not correctly handle 0-length folded-case strings
-                        u_memcpy(fold1, p, length);
-                        foldOffset1 = 0;
-                        foldLength1 = length;
-                        U16_NEXT_UNSAFE(fold1, foldOffset1, c1);
-                    } else {
-                        c1 = length;
-                    }
-                }
-            }
-            
-            if (limit1 >= 0) {
-                index1 = UTEXT_GETNATIVEINDEX(s1);
-            }
-        }
-        
-        if(foldOffset2 < foldLength2) {
-            U16_NEXT_UNSAFE(fold2, foldOffset2, c2);
-        } else {
-            c2 = UTEXT_NEXT32(s2);
-            if (c2 != U_SENTINEL) {
-                length = ucase_toFullFolding(csp, c2, &p, options);
-                if(length >= 0) {
-                    if(length <= UCASE_MAX_STRING_LENGTH) {   // !!!: Does not correctly handle 0-length folded-case strings
-                        u_memcpy(fold2, p, length);
-                        foldOffset2 = 0;
-                        foldLength2 = length;
-                        U16_NEXT_UNSAFE(fold2, foldOffset2, c2);
-                    } else {
-                        c2 = length;
-                    }
-                }
-            } else if(c1 == U_SENTINEL) {
-                return 0;
-            }
-            
-            if (limit2 >= 0) {
-                index2 = UTEXT_GETNATIVEINDEX(s2);
-            }
-        }
-        
-        if(c1 != c2) {
-            return (int32_t)c1-(int32_t)c2;
-        }
-    }
-    
-    /* By now at least one of the strings is out of characters */
-    index1 -= foldLength1 - foldOffset1;
-    index2 -= foldLength2 - foldOffset2;
-    
-    if(limit1 >= 0 && index1 >= limit1) {
-        if(index2 >= limit2) {
-            return 0;
-        } else {
-            return -1;
-        }
-    } else {
-        if(index1 >= limit1) {
-            return 0;
-        } else {
-            return 1;
-        }
-    }
-}
-
-
 U_CAPI UBool U_EXPORT2
 utext_isWritable(const UText *ut)
 {
index 2bc91eb7390c90d4a2f4fc2b7d0370349ffb703c..52f19a438ce0dc08815e6b57a3dd2cf5091e1b0a 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 2004-2011, International Business Machines Corporation and
+ * Copyright (c) 2004-2012, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -90,12 +90,30 @@ static void test_assert_string(const char *expected, const UChar *actual, UBool
 #define TEST_ASSERT_STRING(expected, actual, nulTerm) test_assert_string(expected, actual, nulTerm, __FILE__, __LINE__)
              
 
+static UBool equals_utf8_utext(const char *utf8, UText *utext) {
+    int32_t u8i = 0;
+    UChar32 u8c = 0;
+    UChar32 utc = 0;
+    UBool   stringsEqual = TRUE;
+    utext_setNativeIndex(utext, 0);
+    for (;;) {
+        U8_NEXT_UNSAFE(utf8, u8i, u8c);
+        utc = utext_next32(utext);
+        if (u8c == 0 && utc == U_SENTINEL) {
+            break;
+        }
+        if (u8c != utc || u8c == 0) {
+            stringsEqual = FALSE;
+            break;
+        }
+    }
+    return stringsEqual;
+}
+
+
 static void test_assert_utext(const char *expected, UText *actual, const char *file, int line) {
-    UErrorCode status = U_ZERO_ERROR;
-    UText expectedText = UTEXT_INITIALIZER;
-    utext_openUTF8(&expectedText, expected, -1, &status);
     utext_setNativeIndex(actual, 0);
-    if (utext_compare(&expectedText, -1, actual, -1) != 0) {
+    if (!equals_utf8_utext(expected, actual)) {
         UChar32 c;
         log_err("Failure at file %s, line %d, expected \"%s\", got \"", file, line, expected);
         c = utext_next32From(actual, 0);
@@ -109,11 +127,30 @@ static void test_assert_utext(const char *expected, UText *actual, const char *f
         }
         log_err("\"\n");
     }
-    utext_close(&expectedText);
 }
 
+/*
+ * TEST_ASSERT_UTEXT(const char *expected, const UText *actual)
+ *     Note:  Expected is a UTF-8 encoded string, _not_ the system code page.
+ */
 #define TEST_ASSERT_UTEXT(expected, actual) test_assert_utext(expected, actual, __FILE__, __LINE__)
 
+static UBool testUTextEqual(UText *uta, UText *utb) {
+    UChar32 ca = 0;
+    UChar32 cb = 0;
+    utext_setNativeIndex(uta, 0);
+    utext_setNativeIndex(utb, 0);
+    do {
+        ca = utext_next32(uta);
+        cb = utext_next32(utb);
+        if (ca != cb) {
+            break;
+        }
+    } while (ca != U_SENTINEL);
+    return ca == cb;
+}
+
+    
 
 
 static void TestRegexCAPI(void);
@@ -1578,7 +1615,7 @@ static void TestUTextAPI(void) {
         TEST_ASSERT(resultText != &text1);
         utext_setNativeIndex(resultText, 0);
         utext_setNativeIndex(&text1, 0);
-        TEST_ASSERT(utext_compare(resultText, -1, &text1, -1) == 0);
+        TEST_ASSERT(testUTextEqual(resultText, &text1));
         utext_close(resultText);
         
         result = uregex_getText(re, &textLength, &status); /* flattens UText into buffer */
@@ -1588,7 +1625,7 @@ static void TestUTextAPI(void) {
         TEST_ASSERT(resultText != &text1);
         utext_setNativeIndex(resultText, 0);
         utext_setNativeIndex(&text1, 0);
-        TEST_ASSERT(utext_compare(resultText, -1, &text1, -1) == 0);
+        TEST_ASSERT(testUTextEqual(resultText, &text1));
         utext_close(resultText);
 
         /* Then set a UChar * */
@@ -1597,7 +1634,7 @@ static void TestUTextAPI(void) {
         TEST_ASSERT_SUCCESS(status);
         utext_setNativeIndex(resultText, 0);
         utext_setNativeIndex(&text2, 0);
-        TEST_ASSERT(utext_compare(resultText, -1, &text2, -1) == 0);
+        TEST_ASSERT(testUTextEqual(resultText, &text2));
         utext_close(resultText);
         result = uregex_getText(re, &textLength, &status);
         TEST_ASSERT(textLength == 7);
index a4aa7f083d6a6b2f85b10cfde4f4e9fc6754f0d1..01f674d1dfec28f9f915c9776eafd8068c66e029 100644 (file)
@@ -223,6 +223,23 @@ if (status!=errcode) {dataerrln("RegexTest failure at line %d.  Expected status=
 
 #define REGEX_ASSERT_UNISTR(ustr,inv) {if (!(ustr==inv)) {errln("%s:%d: RegexTest failure: REGEX_ASSERT_UNISTR(%s,%s) failed \n", __FILE__, __LINE__, extractToAssertBuf(ustr),inv);};}
 
+
+static UBool testUTextEqual(UText *uta, UText *utb) {
+    UChar32 ca = 0;
+    UChar32 cb = 0;
+    utext_setNativeIndex(uta, 0);
+    utext_setNativeIndex(utb, 0);
+    do {
+        ca = utext_next32(uta);
+        cb = utext_next32(utb);
+        if (ca != cb) {
+            break;
+        }
+    } while (ca != U_SENTINEL);
+    return ca == cb;
+}
+
+
 /**
  * @param expected expected text in UTF-8 (not platform) codepage
  */
@@ -239,7 +256,7 @@ void RegexTest::assertUText(const char *expected, UText *actual, const char *fil
       return;
     }
     utext_setNativeIndex(actual, 0);
-    if (utext_compare(&expectedText, -1, actual, -1) != 0) {
+    if (!testUTextEqual(&expectedText, actual)) {
         char buf[201 /*21*/];
         char expectedBuf[201];
         utextToPrintable(buf, sizeof(buf)/sizeof(buf[0]), actual);
@@ -261,7 +278,7 @@ void RegexTest::assertUTextInvariant(const char *expected, UText *actual, const
       return;
     }
     utext_setNativeIndex(actual, 0);
-    if (utext_compare(&expectedText, -1, actual, -1) != 0) {
+    if (!testUTextEqual(&expectedText, actual)) {
         char buf[201 /*21*/];
         char expectedBuf[201];
         utextToPrintable(buf, sizeof(buf)/sizeof(buf[0]), actual);
@@ -4920,14 +4937,14 @@ void RegexTest::PreAllocatedUTextCAPI () {
         REGEX_ASSERT(resultText == &bufferText);
         utext_setNativeIndex(resultText, 0);
         utext_setNativeIndex(&text1, 0);
-        REGEX_ASSERT(utext_compare(resultText, -1, &text1, -1) == 0);
+        REGEX_ASSERT(testUTextEqual(resultText, &text1));
         
         resultText = uregex_getUText(re, &bufferText, &status);
         REGEX_CHECK_STATUS;
         REGEX_ASSERT(resultText == &bufferText);
         utext_setNativeIndex(resultText, 0);
         utext_setNativeIndex(&text1, 0);
-        REGEX_ASSERT(utext_compare(resultText, -1, &text1, -1) == 0);
+        REGEX_ASSERT(testUTextEqual(resultText, &text1));
 
         /* Then set a UChar * */
         uregex_setText(re, text2Chars, 7, &status);
@@ -4936,7 +4953,7 @@ void RegexTest::PreAllocatedUTextCAPI () {
         REGEX_ASSERT(resultText == &bufferText);
         utext_setNativeIndex(resultText, 0);
         utext_setNativeIndex(&text2, 0);
-        REGEX_ASSERT(utext_compare(resultText, -1, &text2, -1) == 0);
+        REGEX_ASSERT(testUTextEqual(resultText, &text2));
         
         uregex_close(re);
         utext_close(&text1);
index 2482bb4ad2ee2eee121d361d87d2671b4a79442a..418ca99b4a0752b31b357d4b36c0469ec5a78fcc 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 2005-2011, International Business Machines Corporation and
+ * Copyright (c) 2005-2012, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /************************************************************************
@@ -57,8 +57,6 @@ UTextTest::runIndexedTest(int32_t index, UBool exec,
             if (exec) Ticket5560();  break;
         case 4: name = "Ticket6847";
             if (exec) Ticket6847();  break;
-        case 5: name = "ComparisonTest";
-            if (exec) ComparisonTest(); break;
         default: name = "";          break;
     }
 }
@@ -836,480 +834,6 @@ void UTextTest::TestAccessNoClone(const UnicodeString &us, UText *ut, int cpCoun
     delete []buf;
 }
 
-
-//
-//  ComparisonTest()    Check the string comparison functions. Based on UnicodeStringTest::TestCompare()
-//
-void UTextTest::ComparisonTest()
-{
-    UErrorCode status = U_ZERO_ERROR;
-    UnicodeString   test1Str("this is a test");
-    UnicodeString   test2Str("this is a test");
-    UnicodeString   test3Str("this is a test of the emergency broadcast system");
-    UnicodeString   test4Str("never say, \"this is a test\"!!");
-    
-    UText test1 = UTEXT_INITIALIZER;
-    UText test2 = UTEXT_INITIALIZER;
-    UText test3 = UTEXT_INITIALIZER;
-    UText test4 = UTEXT_INITIALIZER;
-    
-    UChar        uniChars[] = { 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 
-                                0x20, 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0 };
-    char            chars[] = { 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 
-                                0x20, 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0 };
-    
-    UText uniCharText = UTEXT_INITIALIZER;
-    UText charText = UTEXT_INITIALIZER;
-    
-    utext_openUnicodeString(&test1, &test1Str, &status);
-    utext_openUnicodeString(&test2, &test2Str, &status);
-    utext_openUnicodeString(&test3, &test3Str, &status);
-    utext_openUnicodeString(&test4, &test4Str, &status);
-
-    utext_openUChars(&uniCharText, uniChars, -1, &status);
-    utext_openUTF8(&charText, chars, -1, &status);
-    
-    TEST_SUCCESS(status);
-        
-    // test utext_compare(), simple
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compare(&test1, -1, &test2, -1) != 0) errln("utext_compare() failed, simple setup");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compare(&test1, -1, &test3, -1) >= 0) errln("utext_compare() failed, simple setup");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test4, 0);
-    if (utext_compare(&test1, -1, &test4, -1) <= 0) errln("utext_compare() failed, simple setup");
-    
-    // test utext_compareNativeLimit(), simple
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compareNativeLimit(&test1, -1, &test2, -1) != 0) errln("utext_compareNativeLimit() failed, simple setup");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compareNativeLimit(&test1, -1, &test3, -1) >= 0) errln("utext_compareNativeLimit() failed, simple setup");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test4, 0);
-    if (utext_compareNativeLimit(&test1, -1, &test4, -1) <= 0) errln("utext_compareNativeLimit() failed, simple setup");
-    
-    // test utext_compare(), one explicit length
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compare(&test1, 14, &test2, -1) != 0) errln("utext_compare() failed, one explicit length");
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compare(&test3, 14, &test2, -1) != 0) errln("utext_compare() failed, one explicit length");
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    UTEXT_SETNATIVEINDEX(&test4, 12);
-    if (utext_compare(&test4, 14, &test2, -1) != 0) errln("utext_compare() failed, one explicit length and offset");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compare(&test3, 18, &test2, -1) <= 0) errln("utext_compare() failed, one explicit length");
-    
-    // test utext_compareNativeLimit(), one explicit length
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compareNativeLimit(&test1, 14, &test2, -1) != 0) errln("utext_compareNativeLimit() failed, one explicit length");
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compareNativeLimit(&test3, 14, &test2, -1) != 0) errln("utext_compareNativeLimit() failed, one explicit length");
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    UTEXT_SETNATIVEINDEX(&test4, 12);
-    if (utext_compareNativeLimit(&test4, 26, &test2, -1) != 0) errln("utext_compareNativeLimit() failed, one explicit length and limit");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compareNativeLimit(&test3, 18, &test2, -1) <= 0) errln("utext_compareNativeLimit() failed, one explicit length");
-    
-    // test utext_compare(), UChar-based UText
-    UTEXT_SETNATIVEINDEX(&uniCharText, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compare(&test2, -1, &uniCharText, -1) != 0) errln("utext_compare() failed, UChar-based UText");
-    UTEXT_SETNATIVEINDEX(&uniCharText, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compare(&test3, -1, &uniCharText, -1) <= 0) errln("utext_compare() failed, UChar-based UText");
-    UTEXT_SETNATIVEINDEX(&uniCharText, 0);
-    UTEXT_SETNATIVEINDEX(&test4, 0);
-    if (utext_compare(&test4, -1, &uniCharText, -1) >= 0) errln("utext_compare() failed, UChar-based UText");
-    
-    // test utext_compareNativeLimit(), UChar-based UText
-    UTEXT_SETNATIVEINDEX(&uniCharText, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compareNativeLimit(&test2, -1, &uniCharText, -1) != 0) errln("utext_compareNativeLimit() failed, UChar-based UText");
-    UTEXT_SETNATIVEINDEX(&uniCharText, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compareNativeLimit(&test3, -1, &uniCharText, -1) <= 0) errln("utext_compareNativeLimit() failed, UChar-based UText");
-    UTEXT_SETNATIVEINDEX(&uniCharText, 0);
-    UTEXT_SETNATIVEINDEX(&test4, 0);
-    if (utext_compareNativeLimit(&test4, -1, &uniCharText, -1) >= 0) errln("utext_compareNativeLimit() failed, UChar-based UText");
-    
-    // test utext_compare(), UTF8-based UText
-    UTEXT_SETNATIVEINDEX(&charText, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compare(&test2, -1, &charText, -1) != 0) errln("utext_compare() failed, UTF8-based UText");
-    UTEXT_SETNATIVEINDEX(&charText, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compare(&test3, -1, &charText, -1) <= 0) errln("utext_compare() failed, UTF8-based UText");
-    UTEXT_SETNATIVEINDEX(&charText, 0);
-    UTEXT_SETNATIVEINDEX(&test4, 0);
-    if (utext_compare(&test4, -1, &charText, -1) >= 0) errln("utext_compare() failed, UTF8-based UText");
-    
-    // test utext_compareNativeLimit(), UTF8-based UText
-    UTEXT_SETNATIVEINDEX(&charText, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compareNativeLimit(&test2, -1, &charText, -1) != 0) errln("utext_compareNativeLimit() failed, UTF8-based UText");
-    UTEXT_SETNATIVEINDEX(&charText, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compareNativeLimit(&test3, -1, &charText, -1) <= 0) errln("utext_compareNativeLimit() failed, UTF8-based UText");
-    UTEXT_SETNATIVEINDEX(&charText, 0);
-    UTEXT_SETNATIVEINDEX(&test4, 0);
-    if (utext_compareNativeLimit(&test4, -1, &charText, -1) >= 0) errln("utext_compareNativeLimit() failed, UTF8-based UText");
-    
-    // test utext_compare(), length
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compare(&test1, -1, &test2, 4) != 0) errln("utext_compare() failed, one length");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compare(&test1, 5, &test2, 4) <= 0) errln("utext_compare() failed, both lengths");
-    
-    // test utext_compareNativeLimit(), limit
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compareNativeLimit(&test1, -1, &test2, 4) != 0) errln("utext_compareNativeLimit() failed, one limit");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compareNativeLimit(&test1, 5, &test2, 4) <= 0) errln("utext_compareNativeLimit() failed, both limits");
-    
-    // test utext_compare(), both explicit offsets and lengths
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compare(&test1, 14, &test2, 14) != 0) errln("utext_compare() failed, both explicit offsets and lengths");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compare(&test1, 14, &test3, 14) != 0) errln("utext_compare() failed, both explicit offsets and lengths");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test4, 12);
-    if (utext_compare(&test1, 14, &test4, 14) != 0) errln("utext_compare() failed, both explicit offsets and lengths");
-    UTEXT_SETNATIVEINDEX(&test1, 10);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compare(&test1, 4, &test2, 4) >= 0) errln("utext_compare() failed, both explicit offsets and lengths");
-    UTEXT_SETNATIVEINDEX(&test1, 10);
-    UTEXT_SETNATIVEINDEX(&test3, 22);
-    if (utext_compare(&test1, 4, &test3, 9) <= 0) errln("utext_compare() failed, both explicit offsets and lengths");
-    UTEXT_SETNATIVEINDEX(&test1, 10);
-    UTEXT_SETNATIVEINDEX(&test4, 22);
-    if (utext_compare(&test1, 4, &test4, 4) != 0) errln("utext_compare() failed, both explicit offsets and lengths");
-    
-    // test utext_compareNativeLimit(), both explicit offsets and limits
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compareNativeLimit(&test1, 14, &test2, 14) != 0) errln("utext_compareNativeLimit() failed, both explicit offsets and limits");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test3, 0);
-    if (utext_compareNativeLimit(&test1, 14, &test3, 14) != 0) errln("utext_compareNativeLimit() failed, both explicit offsets and limits");
-    UTEXT_SETNATIVEINDEX(&test1, 0);
-    UTEXT_SETNATIVEINDEX(&test4, 12);
-    if (utext_compareNativeLimit(&test1, 14, &test4, 26) != 0) errln("utext_compareNativeLimit() failed, both explicit offsets and limits");
-    UTEXT_SETNATIVEINDEX(&test1, 10);
-    UTEXT_SETNATIVEINDEX(&test2, 0);
-    if (utext_compareNativeLimit(&test1, 14, &test2, 4) >= 0) errln("utext_compareNativeLimit() failed, both explicit offsets and limits");
-    UTEXT_SETNATIVEINDEX(&test1, 10);
-    UTEXT_SETNATIVEINDEX(&test3, 22);
-    if (utext_compareNativeLimit(&test1, 14, &test3, 31) <= 0) errln("utext_compareNativeLimit() failed, both explicit offsets and limits");
-    UTEXT_SETNATIVEINDEX(&test1, 10);
-    UTEXT_SETNATIVEINDEX(&test4, 22);
-    if (utext_compareNativeLimit(&test1, 14, &test4, 26) != 0) errln("utext_compareNativeLimit() failed, both explicit offsets and limits");
-    
-    /* test caseCompare() */
-    {
-        static const UChar
-        _mixed[]=               { 0x61, 0x42, 0x131, 0x3a3, 0xdf,       0x130,       0x49,  0xfb03,           0xd93f, 0xdfff, 0 },
-        _otherDefault[]=        { 0x41, 0x62, 0x131, 0x3c3, 0x73, 0x53, 0x69, 0x307, 0x69,  0x46, 0x66, 0x49, 0xd93f, 0xdfff, 0 },
-        _otherExcludeSpecialI[]={ 0x41, 0x62, 0x131, 0x3c3, 0x53, 0x73, 0x69,        0x131, 0x66, 0x46, 0x69, 0xd93f, 0xdfff, 0 },
-        _different[]=           { 0x41, 0x62, 0x131, 0x3c3, 0x73, 0x53, 0x130,       0x49,  0x46, 0x66, 0x49, 0xd93f, 0xdffd, 0 };
-        
-        UText
-        mixed = UTEXT_INITIALIZER,
-        otherDefault = UTEXT_INITIALIZER,
-        otherExcludeSpecialI = UTEXT_INITIALIZER,
-        different = UTEXT_INITIALIZER;
-        
-        utext_openUChars(&mixed, _mixed, -1, &status);
-        utext_openUChars(&otherDefault, _otherDefault, -1, &status);
-        utext_openUChars(&otherExcludeSpecialI, _otherExcludeSpecialI, -1, &status);
-        utext_openUChars(&different, _different, -1, &status);
-        
-        TEST_SUCCESS(status);
-        
-        int32_t result;
-        
-        /* test default options */
-        UTEXT_SETNATIVEINDEX(&mixed, 0);
-        UTEXT_SETNATIVEINDEX(&otherDefault, 0);
-        result = utext_caseCompare(&mixed, -1, &otherDefault, -1, U_FOLD_CASE_DEFAULT, &status);
-        if (0 != result || U_FAILURE(status)) {
-            errln("error: utext_caseCompare (other, default) gives %ld (should be 0) (%s)\n", result, u_errorName(status));
-        }
-        UTEXT_SETNATIVEINDEX(&mixed, 0);
-        UTEXT_SETNATIVEINDEX(&otherDefault, 0);
-        result = utext_caseCompareNativeLimit(&mixed, -1, &otherDefault, -1, U_FOLD_CASE_DEFAULT, &status);
-        if (0 != result || U_FAILURE(status)) {
-            errln("error: utext_caseCompareNativeLimit (other, default) gives %ld (should be 0) (%s)\n", result, u_errorName(status));
-        }
-        
-        /* test excluding special I */
-        UTEXT_SETNATIVEINDEX(&mixed, 0);
-        UTEXT_SETNATIVEINDEX(&otherExcludeSpecialI, 0);
-        result = utext_caseCompare(&mixed, -1, &otherExcludeSpecialI, -1, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &status);
-        if (0 != result || U_FAILURE(status)) {
-            errln("error: utext_caseCompare (otherExcludeSpecialI, U_FOLD_CASE_EXCLUDE_SPECIAL_I) gives %ld (should be 0) (%s)\n", result, u_errorName(status));
-        }
-        UTEXT_SETNATIVEINDEX(&mixed, 0);
-        UTEXT_SETNATIVEINDEX(&otherExcludeSpecialI, 0);
-        result = utext_caseCompareNativeLimit(&mixed, -1, &otherExcludeSpecialI, -1, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &status);
-        if (0 != result || U_FAILURE(status)) {
-            errln("error: utext_caseCompareNativeLimit (otherExcludeSpecialI, U_FOLD_CASE_EXCLUDE_SPECIAL_I) gives %ld (should be 0) (%s)\n", result, u_errorName(status));
-        }
-        UTEXT_SETNATIVEINDEX(&mixed, 0);
-        UTEXT_SETNATIVEINDEX(&otherDefault, 0);
-        result = utext_caseCompare(&mixed, -1, &otherDefault, -1, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &status);
-        if (0 == result || U_FAILURE(status)) {
-            errln("error: utext_caseCompare (other, U_FOLD_CASE_EXCLUDE_SPECIAL_I) gives %ld (should be nonzero) (%s)\n", result, u_errorName(status));
-        }
-        UTEXT_SETNATIVEINDEX(&mixed, 0);
-        UTEXT_SETNATIVEINDEX(&otherDefault, 0);
-        result = utext_caseCompareNativeLimit(&mixed, -1, &otherDefault, -1, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &status);
-        if (0 == result || U_FAILURE(status)) {
-            errln("error: utext_caseCompareNativeLimit (other, U_FOLD_CASE_EXCLUDE_SPECIAL_I) gives %ld (should be nonzero) (%s)\n", result, u_errorName(status));
-        }
-        
-        /* test against different string */
-        UTEXT_SETNATIVEINDEX(&mixed, 0);
-        UTEXT_SETNATIVEINDEX(&different, 0);
-        result = utext_caseCompare(&mixed, -1, &different, -1, U_FOLD_CASE_DEFAULT, &status);
-        if (0 >= result || U_FAILURE(status)) {
-            errln("error: utext_caseCompare (different, default) gives %ld (should be positive) (%s)\n", result, u_errorName(status));
-        }
-        UTEXT_SETNATIVEINDEX(&mixed, 0);
-        UTEXT_SETNATIVEINDEX(&different, 0);
-        result = utext_caseCompareNativeLimit(&mixed, -1, &different, -1, U_FOLD_CASE_DEFAULT, &status);
-        if (0 >= result || U_FAILURE(status)) {
-            errln("error: utext_caseCompareNativeLimit (different, default) gives %ld (should be positive) (%s)\n", result, u_errorName(status));
-        }
-
-        /* test caseCompare() - include the folded sharp s (U+00df) with different lengths */
-        UTEXT_SETNATIVEINDEX(&mixed, 1);
-        UTEXT_SETNATIVEINDEX(&different, 1);
-        result = utext_caseCompare(&mixed, 4, &different, 5, U_FOLD_CASE_DEFAULT, &status);
-        if (0 != result || U_FAILURE(status)) {
-            errln("error: utext_caseCompare (mixed[1-5), different[1-6), default) gives %ld (should be 0) (%s)\n", result, u_errorName(status));
-        }
-        UTEXT_SETNATIVEINDEX(&mixed, 1);
-        UTEXT_SETNATIVEINDEX(&different, 1);
-        result = utext_caseCompareNativeLimit(&mixed, 5, &different, 6, U_FOLD_CASE_DEFAULT, &status);
-        if (0 != result || U_FAILURE(status)) {
-            errln("error: utext_caseCompareNativeLimit (mixed[1-5), different[1-6), default) gives %ld (should be 0) (%s)\n", result, u_errorName(status));
-        }
-
-        /* test caseCompare() - stop in the middle of the sharp s (U+00df) */
-        UTEXT_SETNATIVEINDEX(&mixed, 1);
-        UTEXT_SETNATIVEINDEX(&different, 1);
-        result = utext_caseCompare(&mixed, 4, &different, 4, U_FOLD_CASE_DEFAULT, &status);
-        if (0 >= result || U_FAILURE(status)) {
-            errln("error: utext_caseCompare (mixed[1-5), different[1-5), default) gives %ld (should be positive) (%s)\n", result, u_errorName(status));
-        }
-        UTEXT_SETNATIVEINDEX(&mixed, 1);
-        UTEXT_SETNATIVEINDEX(&different, 1);
-        result = utext_caseCompareNativeLimit(&mixed, 5, &different, 5, U_FOLD_CASE_DEFAULT, &status);
-        if (0 >= result || U_FAILURE(status)) {
-            errln("error: utext_caseCompareNativeLimit (mixed[1-5), different[1-5), default) gives %ld (should be positive) (%s)\n", result, u_errorName(status));
-        }
-    }
-    
-    /* test surrogates in comparison */
-    {
-        static const UChar
-        _before[] = { 0x65, 0xd800, 0xd800, 0xdc01, 0x65, 0x00 },
-        _after[]  = { 0x65, 0xd800, 0xdc00, 0x65, 0x00 };
-        
-        UText
-        before = UTEXT_INITIALIZER,
-        after  = UTEXT_INITIALIZER;
-        
-        utext_openUChars(&before, _before, -1, &status);
-        utext_openUChars(&after, _after, -1, &status);
-        
-        TEST_SUCCESS(status);
-        int32_t result;
-        
-        UTEXT_SETNATIVEINDEX(&before, 1);
-        UTEXT_SETNATIVEINDEX(&after, 1);
-        result = utext_compare(&before, -1, &after, -1);
-        if (0 <= result || U_FAILURE(status)) {
-            errln("error: utext_compare ({ 65, d800, 10001, 65 }, { 65, 10000, 65 }) gives %ld (should be negative) (%s)\n", result, u_errorName(status));
-        }
-        
-        UTEXT_SETNATIVEINDEX(&before, 1);
-        UTEXT_SETNATIVEINDEX(&after, 1);
-        result = utext_compare(&before, 3, &after, 3);
-        if (0 <= result || U_FAILURE(status)) {
-            errln("error: utext_compare with lengths ({ 65, d800, 10001, 65 }, { 65, 10000, 65 }) gives %ld (should be negative) (%s)\n", result, u_errorName(status));
-        }
-        
-        UTEXT_SETNATIVEINDEX(&before, 1);
-        UTEXT_SETNATIVEINDEX(&after, 1);
-        result = utext_caseCompare(&before, -1, &after, -1, U_FOLD_CASE_DEFAULT, &status);
-        if (0 <= result || U_FAILURE(status)) {
-            errln("error: utext_caseCompare ({ 65, d800, 10001, 65 }, { 65, 10000, 65 }) gives %ld (should be negative) (%s)\n", result, u_errorName(status));
-        }
-        
-        UTEXT_SETNATIVEINDEX(&before, 1);
-        UTEXT_SETNATIVEINDEX(&after, 1);
-        result = utext_caseCompare(&before, 3, &after, 3, U_FOLD_CASE_DEFAULT, &status);
-        if (0 <= result || U_FAILURE(status)) {
-            errln("error: utext_caseCompare with lengths ({ 65, d800, 10001, 65 }, { 65, 10000, 65 }) gives %ld (should be negative) (%s)\n", result, u_errorName(status));
-        }
-        
-        utext_close(&before);
-        utext_close(&after);
-    }
-    
-    /* test surrogates at end of string */
-    {
-        static const UChar
-        _before[] = { 0x65, 0xd800, 0xd800, 0xdc01, 0x00 },
-        _after[]  = { 0x65, 0xd800, 0xdc00, 0x00 };
-        
-        UText
-        before = UTEXT_INITIALIZER,
-        after  = UTEXT_INITIALIZER;
-        
-        utext_openUChars(&before, _before, -1, &status);
-        utext_openUChars(&after, _after, -1, &status);
-        
-        TEST_SUCCESS(status);
-        int32_t result;
-        
-        UTEXT_SETNATIVEINDEX(&before, 1);
-        UTEXT_SETNATIVEINDEX(&after, 1);
-        result = utext_compare(&before, -1, &after, -1);
-        if (0 <= result || U_FAILURE(status)) {
-            errln("error: utext_compare ({ 65, d800, 10001 }, { 65, 10000 }) gives %ld (should be negative) (%s)\n", result, u_errorName(status));
-        }
-        
-        UTEXT_SETNATIVEINDEX(&before, 1);
-        UTEXT_SETNATIVEINDEX(&after, 1);
-        result = utext_caseCompare(&before, -1, &after, -1, U_FOLD_CASE_DEFAULT, &status);
-        if (0 <= result || U_FAILURE(status)) {
-            errln("error: utext_caseCompare ({ 65, d800, 10001 }, { 65, 10000 }) gives %ld (should be negative) (%s)\n", result, u_errorName(status));
-        }
-        
-        utext_close(&before);
-        utext_close(&after);
-    }
-    
-    /* test empty strings */
-    {
-        UChar zero16 = 0;
-        char zero8 = 0;
-        UText emptyUChar = UTEXT_INITIALIZER;
-        UText emptyUTF8 = UTEXT_INITIALIZER;
-        UText nullUChar = UTEXT_INITIALIZER;
-        UText nullUTF8 = UTEXT_INITIALIZER;
-        
-        utext_openUChars(&emptyUChar, &zero16, -1, &status);
-        utext_openUTF8(&emptyUTF8, &zero8, -1, &status);
-        utext_openUChars(&nullUChar, NULL, 0, &status);
-        utext_openUTF8(&nullUTF8, NULL, 0, &status);
-        
-        if (utext_compare(&emptyUChar, -1, &emptyUTF8, -1) != 0) {
-            errln("error: utext_compare(&emptyUChar, -1, &emptyUTF8, -1) != 0");
-        }
-        if (utext_compare(&emptyUChar, -1, &nullUChar, -1) != 0) {
-            errln("error: utext_compare(&emptyUChar, -1, &nullUChar, -1) != 0");
-        }
-        if (utext_compare(&emptyUChar, -1, &nullUTF8, -1) != 0) {
-            errln("error: utext_compare(&emptyUChar, -1, &nullUTF8, -1) != 0");
-        }
-        if (utext_compare(&emptyUTF8, -1, &nullUChar, -1) != 0) {
-            errln("error: utext_compare(&emptyUTF8, -1, &nullUChar, -1) != 0");
-        }
-        if (utext_compare(&emptyUTF8, -1, &nullUTF8, -1) != 0) {
-            errln("error: utext_compare(&emptyUTF8, -1, &nullUTF8, -1) != 0");
-        }
-        if (utext_compare(&nullUChar, -1, &nullUTF8, -1) != 0) {
-            errln("error: utext_compare(&nullUChar, -1, &nullUTF8, -1) != 0");
-        }
-
-        if (utext_compareNativeLimit(&emptyUChar, -1, &emptyUTF8, -1) != 0) {
-            errln("error: utext_compareNativeLimit(&emptyUChar, -1, &emptyUTF8, -1) != 0");
-        }
-        if (utext_compareNativeLimit(&emptyUChar, -1, &nullUChar, -1) != 0) {
-            errln("error: utext_compareNativeLimit(&emptyUChar, -1, &nullUChar, -1) != 0");
-        }
-        if (utext_compareNativeLimit(&emptyUChar, -1, &nullUTF8, -1) != 0) {
-            errln("error: utext_compareNativeLimit(&emptyUChar, -1, &nullUTF8, -1) != 0");
-        }
-        if (utext_compareNativeLimit(&emptyUTF8, -1, &nullUChar, -1) != 0) {
-            errln("error: utext_compareNativeLimit(&emptyUTF8, -1, &nullUChar, -1) != 0");
-        }
-        if (utext_compareNativeLimit(&emptyUTF8, -1, &nullUTF8, -1) != 0) {
-            errln("error: utext_compareNativeLimit(&emptyUTF8, -1, &nullUTF8, -1) != 0");
-        }
-        if (utext_compareNativeLimit(&nullUChar, -1, &nullUTF8, -1) != 0) {
-            errln("error: utext_compareNativeLimit(&nullUChar, -1, &nullUTF8, -1) != 0");
-        }
-
-        if (utext_caseCompare(&emptyUChar, -1, &emptyUTF8, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompare(&emptyUChar, -1, &emptyUTF8, -1, 0, &status) != 0");
-        }
-        if (utext_caseCompare(&emptyUChar, -1, &nullUChar, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompare(&emptyUChar, -1, &nullUChar, -1, 0, &status) != 0");
-        }
-        if (utext_caseCompare(&emptyUChar, -1, &nullUTF8, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompare(&emptyUChar, -1, &nullUTF8, -1, 0, &status) != 0");
-        }
-        if (utext_caseCompare(&emptyUTF8, -1, &nullUChar, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompare(&emptyUTF8, -1, &nullUChar, -1, 0, &status) != 0");
-        }
-        if (utext_caseCompare(&emptyUTF8, -1, &nullUTF8, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompare(&emptyUTF8, -1, &nullUTF8, -1, 0, &status) != 0");
-        }
-        if (utext_caseCompare(&nullUChar, -1, &nullUTF8, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompare(&nullUChar, -1, &nullUTF8, -1, 0, &status) != 0");
-        }
-
-        if (utext_caseCompareNativeLimit(&emptyUChar, -1, &emptyUTF8, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompareNativeLimit(&emptyUChar, -1, &emptyUTF8, -1, 0, &status) != 0");
-        }
-        if (utext_caseCompareNativeLimit(&emptyUChar, -1, &nullUChar, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompareNativeLimit(&emptyUChar, -1, &nullUChar, -1, 0, &status) != 0");
-        }
-        if (utext_caseCompareNativeLimit(&emptyUChar, -1, &nullUTF8, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompareNativeLimit(&emptyUChar, -1, &nullUTF8, -1, 0, &status) != 0");
-        }
-        if (utext_caseCompareNativeLimit(&emptyUTF8, -1, &nullUChar, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompareNativeLimit(&emptyUTF8, -1, &nullUChar, -1, 0, &status) != 0");
-        }
-        if (utext_caseCompareNativeLimit(&emptyUTF8, -1, &nullUTF8, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompareNativeLimit(&emptyUTF8, -1, &nullUTF8, -1, 0, &status) != 0");
-        }
-        if (utext_caseCompareNativeLimit(&nullUChar, -1, &nullUTF8, -1, 0, &status) != 0) {
-            errln("error: utext_caseCompareNativeLimit(&nullUChar, -1, &nullUTF8, -1, 0, &status) != 0");
-        }
-        
-        utext_close(&emptyUChar);
-        utext_close(&emptyUTF8);
-        utext_close(&nullUChar);
-        utext_close(&nullUTF8);
-        utext_close(&charText);
-        utext_close(&uniCharText);
-    }
-}
-
-
-
 //
 //  ErrorTest()    Check various error and edge cases.
 //
index e34f564c3444d03a44d35de034a49b30002bfae0..ff3807921e0558117b087a5ee48745706d8974e8 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 2005-2010, International Business Machines Corporation and
+ * Copyright (c) 2005-2012, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /************************************************************************
@@ -33,7 +33,6 @@ public:
     void FreezeTest();
     void Ticket5560();
     void Ticket6847();
-    void ComparisonTest();
 
 private:
     struct m {                              // Map between native indices & code points.