Home | History | Annotate | Download | only in intltest
      1 /*
      2 *******************************************************************************
      3 *
      4 *   Copyright (C) 2002-2009, International Business Machines
      5 *   Corporation and others.  All Rights Reserved.
      6 *
      7 *******************************************************************************
      8 *   file name:  strcase.cpp
      9 *   encoding:   US-ASCII
     10 *   tab size:   8 (not used)
     11 *   indentation:4
     12 *
     13 *   created on: 2002mar12
     14 *   created by: Markus W. Scherer
     15 *
     16 *   Test file for string casing C++ API functions.
     17 */
     18 
     19 #include "unicode/uchar.h"
     20 #include "unicode/ures.h"
     21 #include "unicode/uloc.h"
     22 #include "unicode/locid.h"
     23 #include "unicode/ubrk.h"
     24 #include "unicode/unistr.h"
     25 #include "unicode/ucasemap.h"
     26 #include "ustrtest.h"
     27 #include "unicode/tstdtmod.h"
     28 
     29 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
     30 
     31 StringCaseTest::~StringCaseTest() {}
     32 
     33 void
     34 StringCaseTest::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) {
     35     if (exec) logln("TestSuite StringCaseTest: ");
     36     switch (index) {
     37         case 0: name = "TestCaseConversion"; if (exec) TestCaseConversion(); break;
     38         case 1:
     39             name = "TestCasing";
     40 #if !UCONFIG_NO_BREAK_ITERATION
     41             if(exec) TestCasing();
     42 #endif
     43             break;
     44 
     45         default: name = ""; break; //needed to end loop
     46     }
     47 }
     48 
     49 void
     50 StringCaseTest::TestCaseConversion()
     51 {
     52     static const UChar uppercaseGreek[] =
     53         { 0x399, 0x395, 0x3a3, 0x3a5, 0x3a3, 0x20, 0x03a7, 0x3a1, 0x399, 0x3a3, 0x3a4,
     54         0x39f, 0x3a3, 0 };
     55         // "IESUS CHRISTOS"
     56 
     57     static const UChar lowercaseGreek[] =
     58         { 0x3b9, 0x3b5, 0x3c3, 0x3c5, 0x3c2, 0x20, 0x03c7, 0x3c1, 0x3b9, 0x3c3, 0x3c4,
     59         0x3bf, 0x3c2, 0 };
     60         // "iesus christos"
     61 
     62     static const UChar lowercaseTurkish[] =
     63         { 0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0x2c, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x63, 0x6f,
     64         0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x0131, 0x6e, 0x6f, 0x70, 0x6c, 0x65, 0x21, 0 };
     65 
     66     static const UChar uppercaseTurkish[] =
     67         { 0x54, 0x4f, 0x50, 0x4b, 0x41, 0x50, 0x49, 0x20, 0x50, 0x41, 0x4c, 0x41, 0x43, 0x45, 0x2c, 0x20,
     68         0x0130, 0x53, 0x54, 0x41, 0x4e, 0x42, 0x55, 0x4c, 0 };
     69 
     70     UnicodeString expectedResult;
     71     UnicodeString   test3;
     72 
     73     test3 += (UChar32)0x0130;
     74     test3 += "STANBUL, NOT CONSTANTINOPLE!";
     75 
     76     UnicodeString   test4(test3);
     77     test4.toLower(Locale(""));
     78     expectedResult = UnicodeString("i\\u0307stanbul, not constantinople!", "").unescape();
     79     if (test4 != expectedResult)
     80         errln("1. toLower failed: expected \"" + expectedResult + "\", got \"" + test4 + "\".");
     81 
     82     test4 = test3;
     83     test4.toLower(Locale("tr", "TR"));
     84     expectedResult = lowercaseTurkish;
     85     if (test4 != expectedResult)
     86         errln("2. toLower failed: expected \"" + expectedResult + "\", got \"" + test4 + "\".");
     87 
     88     test3 = "topkap";
     89     test3 += (UChar32)0x0131;
     90     test3 += " palace, istanbul";
     91     test4 = test3;
     92 
     93     test4.toUpper(Locale(""));
     94     expectedResult = "TOPKAPI PALACE, ISTANBUL";
     95     if (test4 != expectedResult)
     96         errln("toUpper failed: expected \"" + expectedResult + "\", got \"" + test4 + "\".");
     97 
     98     test4 = test3;
     99     test4.toUpper(Locale("tr", "TR"));
    100     expectedResult = uppercaseTurkish;
    101     if (test4 != expectedResult)
    102         errln("toUpper failed: expected \"" + expectedResult + "\", got \"" + test4 + "\".");
    103 
    104     test3 = CharsToUnicodeString("S\\u00FC\\u00DFmayrstra\\u00DFe");
    105 
    106     test3.toUpper(Locale("de", "DE"));
    107     expectedResult = CharsToUnicodeString("S\\u00DCSSMAYRSTRASSE");
    108     if (test3 != expectedResult)
    109         errln("toUpper failed: expected \"" + expectedResult + "\", got \"" + test3 + "\".");
    110 
    111     test4.replace(0, test4.length(), uppercaseGreek);
    112 
    113     test4.toLower(Locale("el", "GR"));
    114     expectedResult = lowercaseGreek;
    115     if (test4 != expectedResult)
    116         errln("toLower failed: expected \"" + expectedResult + "\", got \"" + test4 + "\".");
    117 
    118     test4.replace(0, test4.length(), lowercaseGreek);
    119 
    120     test4.toUpper();
    121     expectedResult = uppercaseGreek;
    122     if (test4 != expectedResult)
    123         errln("toUpper failed: expected \"" + expectedResult + "\", got \"" + test4 + "\".");
    124 
    125     // more string case mapping tests with the new implementation
    126     {
    127         static const UChar
    128 
    129         beforeLower[]= { 0x61, 0x42, 0x49,  0x3a3, 0xdf, 0x3a3, 0x2f, 0xd93f, 0xdfff },
    130         lowerRoot[]=   { 0x61, 0x62, 0x69,  0x3c3, 0xdf, 0x3c2, 0x2f, 0xd93f, 0xdfff },
    131         lowerTurkish[]={ 0x61, 0x62, 0x131, 0x3c3, 0xdf, 0x3c2, 0x2f, 0xd93f, 0xdfff },
    132 
    133         beforeUpper[]= { 0x61, 0x42, 0x69,  0x3c2, 0xdf,       0x3c3, 0x2f, 0xfb03,           0xfb03,           0xfb03,           0xd93f, 0xdfff },
    134         upperRoot[]=   { 0x41, 0x42, 0x49,  0x3a3, 0x53, 0x53, 0x3a3, 0x2f, 0x46, 0x46, 0x49, 0x46, 0x46, 0x49, 0x46, 0x46, 0x49, 0xd93f, 0xdfff },
    135         upperTurkish[]={ 0x41, 0x42, 0x130, 0x3a3, 0x53, 0x53, 0x3a3, 0x2f, 0x46, 0x46, 0x49, 0x46, 0x46, 0x49, 0x46, 0x46, 0x49, 0xd93f, 0xdfff },
    136 
    137         beforeMiniUpper[]=  { 0xdf, 0x61 },
    138         miniUpper[]=        { 0x53, 0x53, 0x41 };
    139 
    140         UnicodeString s;
    141 
    142         /* lowercase with root locale */
    143         s=UnicodeString(FALSE, beforeLower, (int32_t)(sizeof(beforeLower)/U_SIZEOF_UCHAR));
    144         s.toLower("");
    145         if( s.length()!=(sizeof(lowerRoot)/U_SIZEOF_UCHAR) ||
    146             s!=UnicodeString(FALSE, lowerRoot, s.length())
    147         ) {
    148             errln("error in toLower(root locale)=\"" + s + "\" expected \"" + UnicodeString(FALSE, lowerRoot, (int32_t)(sizeof(lowerRoot)/U_SIZEOF_UCHAR)) + "\"");
    149         }
    150 
    151         /* lowercase with turkish locale */
    152         s=UnicodeString(FALSE, beforeLower, (int32_t)(sizeof(beforeLower)/U_SIZEOF_UCHAR));
    153         s.setCharAt(0, beforeLower[0]).toLower(Locale("tr"));
    154         if( s.length()!=(sizeof(lowerTurkish)/U_SIZEOF_UCHAR) ||
    155             s!=UnicodeString(FALSE, lowerTurkish, s.length())
    156         ) {
    157             errln("error in toLower(turkish locale)=\"" + s + "\" expected \"" + UnicodeString(FALSE, lowerTurkish, (int32_t)(sizeof(lowerTurkish)/U_SIZEOF_UCHAR)) + "\"");
    158         }
    159 
    160         /* uppercase with root locale */
    161         s=UnicodeString(FALSE, beforeUpper, (int32_t)(sizeof(beforeUpper)/U_SIZEOF_UCHAR));
    162         s.setCharAt(0, beforeUpper[0]).toUpper(Locale(""));
    163         if( s.length()!=(sizeof(upperRoot)/U_SIZEOF_UCHAR) ||
    164             s!=UnicodeString(FALSE, upperRoot, s.length())
    165         ) {
    166             errln("error in toUpper(root locale)=\"" + s + "\" expected \"" + UnicodeString(FALSE, upperRoot, (int32_t)(sizeof(upperRoot)/U_SIZEOF_UCHAR)) + "\"");
    167         }
    168 
    169         /* uppercase with turkish locale */
    170         s=UnicodeString(FALSE, beforeUpper, (int32_t)(sizeof(beforeUpper)/U_SIZEOF_UCHAR));
    171         s.toUpper(Locale("tr"));
    172         if( s.length()!=(sizeof(upperTurkish)/U_SIZEOF_UCHAR) ||
    173             s!=UnicodeString(FALSE, upperTurkish, s.length())
    174         ) {
    175             errln("error in toUpper(turkish locale)=\"" + s + "\" expected \"" + UnicodeString(FALSE, upperTurkish, (int32_t)(sizeof(upperTurkish)/U_SIZEOF_UCHAR)) + "\"");
    176         }
    177 
    178         /* uppercase a short string with root locale */
    179         s=UnicodeString(FALSE, beforeMiniUpper, (int32_t)(sizeof(beforeMiniUpper)/U_SIZEOF_UCHAR));
    180         s.setCharAt(0, beforeMiniUpper[0]).toUpper("");
    181         if( s.length()!=(sizeof(miniUpper)/U_SIZEOF_UCHAR) ||
    182             s!=UnicodeString(FALSE, miniUpper, s.length())
    183         ) {
    184             errln("error in toUpper(root locale)=\"" + s + "\" expected \"" + UnicodeString(FALSE, miniUpper, (int32_t)(sizeof(miniUpper)/U_SIZEOF_UCHAR)) + "\"");
    185         }
    186     }
    187 
    188     // test some supplementary characters (>= Unicode 3.1)
    189     {
    190         UnicodeString t;
    191 
    192         UnicodeString
    193             deseretInput=UnicodeString("\\U0001043C\\U00010414", "").unescape(),
    194             deseretLower=UnicodeString("\\U0001043C\\U0001043C", "").unescape(),
    195             deseretUpper=UnicodeString("\\U00010414\\U00010414", "").unescape();
    196         (t=deseretInput).toLower();
    197         if(t!=deseretLower) {
    198             errln("error lowercasing Deseret (plane 1) characters");
    199         }
    200         (t=deseretInput).toUpper();
    201         if(t!=deseretUpper) {
    202             errln("error uppercasing Deseret (plane 1) characters");
    203         }
    204     }
    205 
    206     // test some more cases that looked like problems
    207     {
    208         UnicodeString t;
    209 
    210         UnicodeString
    211             ljInput=UnicodeString("ab'cD \\uFB00i\\u0131I\\u0130 \\u01C7\\u01C8\\u01C9 \\U0001043C\\U00010414", "").unescape(),
    212             ljLower=UnicodeString("ab'cd \\uFB00i\\u0131ii\\u0307 \\u01C9\\u01C9\\u01C9 \\U0001043C\\U0001043C", "").unescape(),
    213             ljUpper=UnicodeString("AB'CD FFIII\\u0130 \\u01C7\\u01C7\\u01C7 \\U00010414\\U00010414", "").unescape();
    214         (t=ljInput).toLower("en");
    215         if(t!=ljLower) {
    216             errln("error lowercasing LJ characters");
    217         }
    218         (t=ljInput).toUpper("en");
    219         if(t!=ljUpper) {
    220             errln("error uppercasing LJ characters");
    221         }
    222     }
    223 
    224 #if !UCONFIG_NO_NORMALIZATION
    225     // some context-sensitive casing depends on normalization data being present
    226 
    227     // Unicode 3.1.1 SpecialCasing tests
    228     {
    229         UnicodeString t;
    230 
    231         // sigmas preceded and/or followed by cased letters
    232         UnicodeString
    233             sigmas=UnicodeString("i\\u0307\\u03a3\\u0308j \\u0307\\u03a3\\u0308j i\\u00ad\\u03a3\\u0308 \\u0307\\u03a3\\u0308 ", "").unescape(),
    234             sigmasLower=UnicodeString("i\\u0307\\u03c3\\u0308j \\u0307\\u03c3\\u0308j i\\u00ad\\u03c2\\u0308 \\u0307\\u03c3\\u0308 ", "").unescape(),
    235             sigmasUpper=UnicodeString("I\\u0307\\u03a3\\u0308J \\u0307\\u03a3\\u0308J I\\u00ad\\u03a3\\u0308 \\u0307\\u03a3\\u0308 ", "").unescape();
    236 
    237         (t=sigmas).toLower();
    238         if(t!=sigmasLower) {
    239             errln("error in sigmas.toLower()=\"" + t + "\" expected \"" + sigmasLower + "\"");
    240         }
    241 
    242         (t=sigmas).toUpper(Locale(""));
    243         if(t!=sigmasUpper) {
    244             errln("error in sigmas.toUpper()=\"" + t + "\" expected \"" + sigmasUpper + "\"");
    245         }
    246 
    247         // turkish & azerbaijani dotless i & dotted I
    248         // remove dot above if there was a capital I before and there are no more accents above
    249         UnicodeString
    250             dots=UnicodeString("I \\u0130 I\\u0307 I\\u0327\\u0307 I\\u0301\\u0307 I\\u0327\\u0307\\u0301", "").unescape(),
    251             dotsTurkish=UnicodeString("\\u0131 i i i\\u0327 \\u0131\\u0301\\u0307 i\\u0327\\u0301", "").unescape(),
    252             dotsDefault=UnicodeString("i i\\u0307 i\\u0307 i\\u0327\\u0307 i\\u0301\\u0307 i\\u0327\\u0307\\u0301", "").unescape();
    253 
    254         (t=dots).toLower("tr");
    255         if(t!=dotsTurkish) {
    256             errln("error in dots.toLower(tr)=\"" + t + "\" expected \"" + dotsTurkish + "\"");
    257         }
    258 
    259         (t=dots).toLower("de");
    260         if(t!=dotsDefault) {
    261             errln("error in dots.toLower(de)=\"" + t + "\" expected \"" + dotsDefault + "\"");
    262         }
    263     }
    264 
    265     // more Unicode 3.1.1 tests
    266     {
    267         UnicodeString t;
    268 
    269         // lithuanian dot above in uppercasing
    270         UnicodeString
    271             dots=UnicodeString("a\\u0307 \\u0307 i\\u0307 j\\u0327\\u0307 j\\u0301\\u0307", "").unescape(),
    272             dotsLithuanian=UnicodeString("A\\u0307 \\u0307 I J\\u0327 J\\u0301\\u0307", "").unescape(),
    273             dotsDefault=UnicodeString("A\\u0307 \\u0307 I\\u0307 J\\u0327\\u0307 J\\u0301\\u0307", "").unescape();
    274 
    275         (t=dots).toUpper("lt");
    276         if(t!=dotsLithuanian) {
    277             errln("error in dots.toUpper(lt)=\"" + t + "\" expected \"" + dotsLithuanian + "\"");
    278         }
    279 
    280         (t=dots).toUpper("de");
    281         if(t!=dotsDefault) {
    282             errln("error in dots.toUpper(de)=\"" + t + "\" expected \"" + dotsDefault + "\"");
    283         }
    284 
    285         // lithuanian adds dot above to i in lowercasing if there are more above accents
    286         UnicodeString
    287             i=UnicodeString("I I\\u0301 J J\\u0301 \\u012e \\u012e\\u0301 \\u00cc\\u00cd\\u0128", "").unescape(),
    288             iLithuanian=UnicodeString("i i\\u0307\\u0301 j j\\u0307\\u0301 \\u012f \\u012f\\u0307\\u0301 i\\u0307\\u0300i\\u0307\\u0301i\\u0307\\u0303", "").unescape(),
    289             iDefault=UnicodeString("i i\\u0301 j j\\u0301 \\u012f \\u012f\\u0301 \\u00ec\\u00ed\\u0129", "").unescape();
    290 
    291         (t=i).toLower("lt");
    292         if(t!=iLithuanian) {
    293             errln("error in i.toLower(lt)=\"" + t + "\" expected \"" + iLithuanian + "\"");
    294         }
    295 
    296         (t=i).toLower("de");
    297         if(t!=iDefault) {
    298             errln("error in i.toLower(de)=\"" + t + "\" expected \"" + iDefault + "\"");
    299         }
    300     }
    301 
    302 #endif
    303 
    304     // test case folding
    305     {
    306         UnicodeString
    307             s=UnicodeString("A\\u00df\\u00b5\\ufb03\\U0001040c\\u0130\\u0131", "").unescape(),
    308             f=UnicodeString("ass\\u03bcffi\\U00010434i\\u0307\\u0131", "").unescape(),
    309             g=UnicodeString("ass\\u03bcffi\\U00010434i\\u0131", "").unescape(),
    310             t;
    311 
    312         (t=s).foldCase();
    313         if(f!=t) {
    314             errln("error in foldCase(\"" + s + "\", default)=\"" + t + "\" but expected \"" + f + "\"");
    315         }
    316 
    317         // alternate handling for dotted I/dotless i (U+0130, U+0131)
    318         (t=s).foldCase(U_FOLD_CASE_EXCLUDE_SPECIAL_I);
    319         if(g!=t) {
    320             errln("error in foldCase(\"" + s + "\", U_FOLD_CASE_EXCLUDE_SPECIAL_I)=\"" + t + "\" but expected \"" + g + "\"");
    321         }
    322     }
    323 }
    324 
    325 // data-driven case mapping tests ------------------------------------------ ***
    326 
    327 enum {
    328     TEST_LOWER,
    329     TEST_UPPER,
    330     TEST_TITLE,
    331     TEST_FOLD,
    332     TEST_COUNT
    333 };
    334 
    335 // names of TestData children in casing.txt
    336 static const char *const dataNames[TEST_COUNT+1]={
    337     "lowercasing",
    338     "uppercasing",
    339     "titlecasing",
    340     "casefolding",
    341     ""
    342 };
    343 
    344 void
    345 StringCaseTest::TestCasingImpl(const UnicodeString &input,
    346                                const UnicodeString &output,
    347                                int32_t whichCase,
    348                                void *iter, const char *localeID, uint32_t options) {
    349     // UnicodeString
    350     UnicodeString result;
    351     const char *name;
    352     Locale locale(localeID);
    353 
    354     result=input;
    355     switch(whichCase) {
    356     case TEST_LOWER:
    357         name="toLower";
    358         result.toLower(locale);
    359         break;
    360     case TEST_UPPER:
    361         name="toUpper";
    362         result.toUpper(locale);
    363         break;
    364 #if !UCONFIG_NO_BREAK_ITERATION
    365     case TEST_TITLE:
    366         name="toTitle";
    367         result.toTitle((BreakIterator *)iter, locale, options);
    368         break;
    369 #endif
    370     case TEST_FOLD:
    371         name="foldCase";
    372         result.foldCase(options);
    373         break;
    374     default:
    375         name="";
    376         break; // won't happen
    377     }
    378     if(result!=output) {
    379         dataerrln("error: UnicodeString.%s() got a wrong result for a test case from casing.res", name);
    380     }
    381 #if !UCONFIG_NO_BREAK_ITERATION
    382     if(whichCase==TEST_TITLE && options==0) {
    383         result=input;
    384         result.toTitle((BreakIterator *)iter, locale);
    385         if(result!=output) {
    386             dataerrln("error: UnicodeString.toTitle(options=0) got a wrong result for a test case from casing.res");
    387         }
    388     }
    389 #endif
    390 
    391     // UTF-8
    392     char utf8In[100], utf8Out[100];
    393     int32_t utf8InLength, utf8OutLength, resultLength;
    394     UChar *buffer;
    395 
    396     UCaseMap *csm;
    397     UErrorCode errorCode;
    398 
    399     errorCode=U_ZERO_ERROR;
    400     csm=ucasemap_open(localeID, options, &errorCode);
    401 #if !UCONFIG_NO_BREAK_ITERATION
    402     if(iter!=NULL) {
    403         // Clone the break iterator so that the UCaseMap can safely adopt it.
    404         int32_t size=1;  // Not 0 because that only gives preflighting.
    405         UBreakIterator *clone=ubrk_safeClone((UBreakIterator *)iter, NULL, &size, &errorCode);
    406         ucasemap_setBreakIterator(csm, clone, &errorCode);
    407     }
    408 #endif
    409 
    410     u_strToUTF8(utf8In, (int32_t)sizeof(utf8In), &utf8InLength, input.getBuffer(), input.length(), &errorCode);
    411     switch(whichCase) {
    412     case TEST_LOWER:
    413         name="ucasemap_utf8ToLower";
    414         utf8OutLength=ucasemap_utf8ToLower(csm,
    415                     utf8Out, (int32_t)sizeof(utf8Out),
    416                     utf8In, utf8InLength, &errorCode);
    417         break;
    418     case TEST_UPPER:
    419         name="ucasemap_utf8ToUpper";
    420         utf8OutLength=ucasemap_utf8ToUpper(csm,
    421                     utf8Out, (int32_t)sizeof(utf8Out),
    422                     utf8In, utf8InLength, &errorCode);
    423         break;
    424 #if !UCONFIG_NO_BREAK_ITERATION
    425     case TEST_TITLE:
    426         name="ucasemap_utf8ToTitle";
    427         utf8OutLength=ucasemap_utf8ToTitle(csm,
    428                     utf8Out, (int32_t)sizeof(utf8Out),
    429                     utf8In, utf8InLength, &errorCode);
    430         break;
    431 #endif
    432     case TEST_FOLD:
    433         name="ucasemap_utf8FoldCase";
    434         utf8OutLength=ucasemap_utf8FoldCase(csm,
    435                     utf8Out, (int32_t)sizeof(utf8Out),
    436                     utf8In, utf8InLength, &errorCode);
    437         break;
    438     default:
    439         name="";
    440         utf8OutLength=0;
    441         break; // won't happen
    442     }
    443     buffer=result.getBuffer(utf8OutLength);
    444     u_strFromUTF8(buffer, result.getCapacity(), &resultLength, utf8Out, utf8OutLength, &errorCode);
    445     result.releaseBuffer(U_SUCCESS(errorCode) ? resultLength : 0);
    446 
    447     if(U_FAILURE(errorCode)) {
    448         errcheckln(errorCode, "error: %s() got an error for a test case from casing.res - %s", name, u_errorName(errorCode));
    449     } else if(result!=output) {
    450         errln("error: %s() got a wrong result for a test case from casing.res", name);
    451         errln("expected \"" + output + "\" got \"" + result + "\"" );
    452     }
    453     ucasemap_close(csm);
    454 }
    455 
    456 void
    457 StringCaseTest::TestCasing() {
    458     UErrorCode status = U_ZERO_ERROR;
    459     void *iter;
    460     char cLocaleID[100];
    461     UnicodeString locale, input, output, optionsString, result;
    462     uint32_t options;
    463     int32_t whichCase, type;
    464     TestDataModule *driver = TestDataModule::getTestDataModule("casing", *this, status);
    465     if(U_SUCCESS(status)) {
    466         for(whichCase=0; whichCase<TEST_COUNT; ++whichCase) {
    467 #if UCONFIG_NO_BREAK_ITERATION
    468             if(whichCase==TEST_TITLE) {
    469                 continue;
    470             }
    471 #endif
    472             TestData *casingTest = driver->createTestData(dataNames[whichCase], status);
    473             if(U_FAILURE(status)) {
    474                 errln("TestCasing failed to createTestData(%s) - %s", dataNames[whichCase], u_errorName(status));
    475                 break;
    476             }
    477             const DataMap *myCase = NULL;
    478             while(casingTest->nextCase(myCase, status)) {
    479                 input = myCase->getString("Input", status);
    480                 output = myCase->getString("Output", status);
    481 
    482                 if(whichCase!=TEST_FOLD) {
    483                     locale = myCase->getString("Locale", status);
    484                 }
    485                 locale.extract(0, 0x7fffffff, cLocaleID, sizeof(cLocaleID), "");
    486 
    487                 iter=NULL;
    488 #if !UCONFIG_NO_BREAK_ITERATION
    489                 if(whichCase==TEST_TITLE) {
    490                     type = myCase->getInt("Type", status);
    491                     if(type>=0) {
    492                         iter=ubrk_open((UBreakIteratorType)type, cLocaleID, NULL, 0, &status);
    493                     } else if(type==-2) {
    494                         // Open a trivial break iterator that only delivers { 0, length }
    495                         // or even just { 0 } as boundaries.
    496                         static const UChar rules[] = { 0x2e, 0x2a, 0x3b };  // ".*;"
    497                         UParseError parseError;
    498                         iter=ubrk_openRules(rules, LENGTHOF(rules), NULL, 0, &parseError, &status);
    499                     }
    500                 }
    501 #endif
    502                 options = 0;
    503                 if(whichCase==TEST_TITLE || whichCase==TEST_FOLD) {
    504                     optionsString = myCase->getString("Options", status);
    505                     if(optionsString.indexOf((UChar)0x54)>=0) {  // T
    506                         options|=U_FOLD_CASE_EXCLUDE_SPECIAL_I;
    507                     }
    508                     if(optionsString.indexOf((UChar)0x4c)>=0) {  // L
    509                         options|=U_TITLECASE_NO_LOWERCASE;
    510                     }
    511                     if(optionsString.indexOf((UChar)0x41)>=0) {  // A
    512                         options|=U_TITLECASE_NO_BREAK_ADJUSTMENT;
    513                     }
    514                 }
    515 
    516                 if(U_FAILURE(status)) {
    517                     dataerrln("error: TestCasing() setup failed for %s test case from casing.res: %s", dataNames[whichCase],  u_errorName(status));
    518                     status = U_ZERO_ERROR;
    519                 } else {
    520                     TestCasingImpl(input, output, whichCase, iter, cLocaleID, options);
    521                 }
    522 
    523 #if !UCONFIG_NO_BREAK_ITERATION
    524                 if(iter!=NULL) {
    525                     ubrk_close(iter);
    526                 }
    527 #endif
    528             }
    529             delete casingTest;
    530         }
    531     }
    532     delete driver;
    533 
    534 #if !UCONFIG_NO_BREAK_ITERATION
    535     // more tests for API coverage
    536     status=U_ZERO_ERROR;
    537     input=UNICODE_STRING_SIMPLE("sTrA\\u00dfE").unescape();
    538     (result=input).toTitle(NULL);
    539     if(result!=UNICODE_STRING_SIMPLE("Stra\\u00dfe").unescape()) {
    540         dataerrln("UnicodeString::toTitle(NULL) failed.");
    541     }
    542 #endif
    543 }
    544