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