]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/tchcfmt.cpp
ICU-57132.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / tchcfmt.cpp
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2016, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6
7 #include "unicode/utypes.h"
8
9 #if !UCONFIG_NO_FORMATTING
10
11 #include "intltest.h"
12 #include "tchcfmt.h"
13 #include "cmemory.h"
14 #include "unicode/msgfmt.h"
15 #include "unicode/choicfmt.h"
16
17 #include <float.h>
18
19 // tests have obvious memory leaks!
20
21 void TestChoiceFormat::runIndexedTest(int32_t index, UBool exec,
22 const char* &name, char* /*par*/) {
23 switch (index) {
24 TESTCASE(0,TestSimpleExample);
25 TESTCASE(1,TestComplexExample);
26 TESTCASE(2,TestClosures);
27 TESTCASE(3,TestPatterns);
28 TESTCASE(4,TestChoiceFormatToPatternOverflow);
29 default: name = ""; break;
30 }
31 }
32
33 static UBool chkstatus( UErrorCode &status, const char* msg = NULL )
34 {
35 UBool ok = U_SUCCESS(status);
36 if (!ok) it_errln( msg );
37 return ok;
38 }
39
40 void
41 TestChoiceFormat::TestSimpleExample( void )
42 {
43 double limits[] = {1,2,3,4,5,6,7};
44 UnicodeString monthNames[] = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
45 ChoiceFormat* form = new ChoiceFormat(limits, monthNames, 7);
46 ParsePosition parse_pos;
47 // TODO Fix this ParsePosition stuff...
48 UnicodeString str;
49 UnicodeString res1, res2;
50 UErrorCode status;
51 FieldPosition fpos(0);
52 Formattable f;
53 int32_t ix;
54 //for (double i = 0.0; i <= 8.0; ++i) {
55 for (ix = 0; ix <= 8; ++ix) {
56 double i = ix; //nos
57 status = U_ZERO_ERROR;
58 fpos = 0;
59 str = "";
60 res1 = form->format(i, str, fpos, status );
61 if (!chkstatus( status, "*** test_simple_example format" )) {
62 delete form;
63 return;
64 }
65 //form->parse(res1, f, parse_pos);
66 res2 = " ??? ";
67 it_logln(UnicodeString("") + ix + UnicodeString(" -> ") + res1 + UnicodeString(" -> ") + res2);
68 }
69 //Testing ==operator
70 const double filelimits[] = {0,1,2};
71 const UnicodeString filepart[] = {"are no files","is one file","are {2} files"};
72 ChoiceFormat* formnew=new ChoiceFormat(filelimits, filepart, 3);
73 ChoiceFormat* formequal=new ChoiceFormat(limits, monthNames, 7);
74 if(*formnew == *form){
75 errln("ERROR: ==operator failed\n");
76 }
77 if(!(*form == *formequal)){
78 errln("ERROR: ==operator failed\n");
79 }
80 delete formequal;
81 delete formnew;
82
83 //Testing getLimits()
84 int32_t count=0;
85 const double *gotLimits=form->getLimits(count);
86 #if 1 // ICU 4.8 deprecates and disables the ChoiceFormat getters.
87 if(count != 0 || gotLimits != NULL) {
88 errln("getLimits() returns something, should be disabled");
89 }
90 const UnicodeString *gotFormats=form->getFormats(count);
91 if(count != 0 || gotFormats != NULL) {
92 errln("getFormats() returns something, should be disabled");
93 }
94 const UBool *gotClosures=form->getClosures(count);
95 if(count != 0 || gotClosures != NULL) {
96 errln("getClosures() returns something, should be disabled");
97 }
98 #else
99 if(count != 7){
100 errln("getLimits didn't update the count correctly\n");
101 }
102 for(ix=0; ix<count; ix++){
103 if(gotLimits[ix] != limits[ix]){
104 errln((UnicodeString)"getLimits didn't get the limits correctly. Expected " + limits[ix] + " Got " + gotLimits[ix]);
105 }
106 }
107 //Testing getFormats()
108 count=0;
109 const UnicodeString *gotFormats=form->getFormats(count);
110 if(count != 7){
111 errln("getFormats didn't update the count correctly\n");
112 }
113 for(ix=0; ix<count; ix++){
114 if(gotFormats[ix] != monthNames[ix]){
115 errln((UnicodeString)"getFormats didn't get the Formats correctly. Expected " + monthNames[ix] + " Got " + gotFormats[ix]);
116 }
117 }
118 #endif
119
120 delete form;
121 }
122
123 void
124 TestChoiceFormat::TestComplexExample( void )
125 {
126 UErrorCode status = U_ZERO_ERROR;
127 const double filelimits[] = {-1, 0,1,2};
128 const UnicodeString filepart[] = {"are corrupted files", "are no files","is one file","are {2} files"};
129
130 ChoiceFormat* fileform = new ChoiceFormat( filelimits, filepart, 4);
131
132 if (!fileform) {
133 it_errln("*** test_complex_example fileform");
134 return;
135 }
136
137 Format* filenumform = NumberFormat::createInstance( status );
138 if (!filenumform) {
139 dataerrln((UnicodeString)"*** test_complex_example filenumform - " + u_errorName(status));
140 delete fileform;
141 return;
142 }
143 if (!chkstatus( status, "*** test_simple_example filenumform" )) {
144 delete fileform;
145 delete filenumform;
146 return;
147 }
148
149 //const Format* testFormats[] = { fileform, NULL, filenumform };
150 //pattform->setFormats( testFormats, 3 );
151
152 MessageFormat* pattform = new MessageFormat("There {0} on {1}", status );
153 if (!pattform) {
154 it_errln("*** test_complex_example pattform");
155 delete fileform;
156 delete filenumform;
157 return;
158 }
159 if (!chkstatus( status, "*** test_complex_example pattform" )) {
160 delete fileform;
161 delete filenumform;
162 delete pattform;
163 return;
164 }
165
166 pattform->setFormat( 0, *fileform );
167 pattform->setFormat( 2, *filenumform );
168
169
170 Formattable testArgs[] = {(int32_t)0, "Disk_A", (int32_t)0};
171 UnicodeString str;
172 UnicodeString res1, res2;
173 pattform->toPattern( res1 );
174 it_logln("MessageFormat toPattern: " + res1);
175 fileform->toPattern( res1 );
176 it_logln("ChoiceFormat toPattern: " + res1);
177 if (res1 == "-1#are corrupted files|0#are no files|1#is one file|2#are {2} files") {
178 it_logln("toPattern tested!");
179 }else{
180 it_errln("*** ChoiceFormat to Pattern result!");
181 }
182
183 FieldPosition fpos(0);
184
185 UnicodeString checkstr[] = {
186 "There are corrupted files on Disk_A",
187 "There are no files on Disk_A",
188 "There is one file on Disk_A",
189 "There are 2 files on Disk_A",
190 "There are 3 files on Disk_A"
191 };
192
193 // if (status != U_ZERO_ERROR) return; // TODO: analyze why we have such a bad bail out here!
194
195 if (U_FAILURE(status)) {
196 delete fileform;
197 delete filenumform;
198 delete pattform;
199 return;
200 }
201
202
203 int32_t i;
204 int32_t start = -1;
205 for (i = start; i < 4; ++i) {
206 str = "";
207 status = U_ZERO_ERROR;
208 testArgs[0] = Formattable((int32_t)i);
209 testArgs[2] = testArgs[0];
210 res2 = pattform->format(testArgs, 3, str, fpos, status );
211 if (!chkstatus( status, "*** test_complex_example format" )) {
212 delete fileform;
213 delete filenumform;
214 delete pattform;
215 return;
216 }
217 it_logln(i + UnicodeString(" -> ") + res2);
218 if (res2 != checkstr[i - start]) {
219 it_errln("*** test_complex_example res string");
220 it_errln(UnicodeString("*** ") + i + UnicodeString(" -> '") + res2 + UnicodeString("' unlike '") + checkstr[i] + UnicodeString("' ! "));
221 }
222 }
223 it_logln();
224
225 it_logln("------ additional testing in complex test ------");
226 it_logln();
227 //
228 #if 0 // ICU 4.8 deprecates and disables the ChoiceFormat getters.
229 int32_t retCount;
230 const double* retLimits = fileform->getLimits( retCount );
231 if ((retCount == 4) && (retLimits)
232 && (retLimits[0] == -1.0)
233 && (retLimits[1] == 0.0)
234 && (retLimits[2] == 1.0)
235 && (retLimits[3] == 2.0)) {
236 it_logln("getLimits tested!");
237 }else{
238 it_errln("*** getLimits unexpected result!");
239 }
240
241 const UnicodeString* retFormats = fileform->getFormats( retCount );
242 if ((retCount == 4) && (retFormats)
243 && (retFormats[0] == "are corrupted files")
244 && (retFormats[1] == "are no files")
245 && (retFormats[2] == "is one file")
246 && (retFormats[3] == "are {2} files")) {
247 it_logln("getFormats tested!");
248 }else{
249 it_errln("*** getFormats unexpected result!");
250 }
251 #endif
252
253 UnicodeString checkstr2[] = {
254 "There is no folder on Disk_A",
255 "There is one folder on Disk_A",
256 "There are many folders on Disk_A",
257 "There are many folders on Disk_A"
258 };
259
260 fileform->applyPattern("0#is no folder|1#is one folder|2#are many folders", status );
261 if (status == U_ZERO_ERROR)
262 it_logln("status applyPattern OK!");
263 if (!chkstatus( status, "*** test_complex_example pattform" )) {
264 delete fileform;
265 delete filenumform;
266 delete pattform;
267 return;
268 }
269 pattform->setFormat( 0, *fileform );
270 fpos = 0;
271 for (i = 0; i < 4; ++i) {
272 str = "";
273 status = U_ZERO_ERROR;
274 testArgs[0] = Formattable((int32_t)i);
275 testArgs[2] = testArgs[0];
276 res2 = pattform->format(testArgs, 3, str, fpos, status );
277 if (!chkstatus( status, "*** test_complex_example format 2" )) {
278 delete fileform;
279 delete filenumform;
280 delete pattform;
281 return;
282 }
283 it_logln(UnicodeString() + i + UnicodeString(" -> ") + res2);
284 if (res2 != checkstr2[i]) {
285 it_errln("*** test_complex_example res string");
286 it_errln(UnicodeString("*** ") + i + UnicodeString(" -> '") + res2 + UnicodeString("' unlike '") + checkstr2[i] + UnicodeString("' ! "));
287 }
288 }
289
290 const double limits_A[] = {1,2,3,4,5,6,7};
291 const UnicodeString monthNames_A[] = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
292 ChoiceFormat* form_A = new ChoiceFormat(limits_A, monthNames_A, 7);
293 ChoiceFormat* form_A2 = new ChoiceFormat(limits_A, monthNames_A, 7);
294 const double limits_B[] = {1,2,3,4,5,6,7};
295 const UnicodeString monthNames_B[] = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat_BBB"};
296 ChoiceFormat* form_B = new ChoiceFormat(limits_B, monthNames_B, 7);
297 if (!form_A || !form_B || !form_A2) {
298 it_errln("*** test-choiceFormat not allocatable!");
299 }else{
300 if (*form_A == *form_A2) {
301 it_logln("operator== tested.");
302 }else{
303 it_errln("*** operator==");
304 }
305
306 if (*form_A != *form_B) {
307 it_logln("operator!= tested.");
308 }else{
309 it_errln("*** operator!=");
310 }
311
312 ChoiceFormat* form_A3 = (ChoiceFormat*) form_A->clone();
313 if (!form_A3) {
314 it_errln("*** ChoiceFormat->clone is nil.");
315 }else{
316 if ((*form_A3 == *form_A) && (*form_A3 != *form_B)) {
317 it_logln("method clone tested.");
318 }else{
319 it_errln("*** ChoiceFormat clone or operator==, or operator!= .");
320 }
321 }
322
323 ChoiceFormat form_Assigned( *form_A );
324 UBool ok = (form_Assigned == *form_A) && (form_Assigned != *form_B);
325 form_Assigned = *form_B;
326 ok = ok && (form_Assigned != *form_A) && (form_Assigned == *form_B);
327 if (ok) {
328 it_logln("copy constructor and operator= tested.");
329 }else{
330 it_errln("*** copy constructor or operator= or operator == or operator != .");
331 }
332 delete form_A3;
333 }
334
335
336 delete form_A; delete form_A2; delete form_B;
337
338 const char* testPattern = "0#none|1#one|2#many";
339 ChoiceFormat form_pat( testPattern, status );
340 if (!chkstatus( status, "*** ChoiceFormat contructor( newPattern, status)" )) {
341 delete fileform;
342 delete filenumform;
343 delete pattform;
344 return;
345 }
346
347 form_pat.toPattern( res1 );
348 if (res1 == "0#none|1#one|2#many") {
349 it_logln("ChoiceFormat contructor( newPattern, status) tested");
350 }else{
351 it_errln("*** ChoiceFormat contructor( newPattern, status) or toPattern result!");
352 }
353
354 double d_a2[] = { 3.0, 4.0 };
355 UnicodeString s_a2[] = { "third", "forth" };
356
357 form_pat.setChoices( d_a2, s_a2, 2 );
358 form_pat.toPattern( res1 );
359 it_logln(UnicodeString("ChoiceFormat adoptChoices toPattern: ") + res1);
360 if (res1 == "3#third|4#forth") {
361 it_logln("ChoiceFormat adoptChoices tested");
362 }else{
363 it_errln("*** ChoiceFormat adoptChoices result!");
364 }
365
366 str = "";
367 fpos = 0;
368 status = U_ZERO_ERROR;
369 double arg_double = 3.0;
370 res1 = form_pat.format( arg_double, str, fpos );
371 it_logln(UnicodeString("ChoiceFormat format:") + res1);
372 if (res1 != "third") it_errln("*** ChoiceFormat format (double, ...) result!");
373
374 str = "";
375 fpos = 0;
376 status = U_ZERO_ERROR;
377 int64_t arg_64 = 3;
378 res1 = form_pat.format( arg_64, str, fpos );
379 it_logln(UnicodeString("ChoiceFormat format:") + res1);
380 if (res1 != "third") it_errln("*** ChoiceFormat format (int64_t, ...) result!");
381
382 str = "";
383 fpos = 0;
384 status = U_ZERO_ERROR;
385 int32_t arg_long = 3;
386 res1 = form_pat.format( arg_long, str, fpos );
387 it_logln(UnicodeString("ChoiceFormat format:") + res1);
388 if (res1 != "third") it_errln("*** ChoiceFormat format (int32_t, ...) result!");
389
390 Formattable ft( (int32_t)3 );
391 str = "";
392 fpos = 0;
393 status = U_ZERO_ERROR;
394 res1 = form_pat.format( ft, str, fpos, status );
395 if (!chkstatus( status, "*** test_complex_example format (int32_t, ...)" )) {
396 delete fileform;
397 delete filenumform;
398 delete pattform;
399 return;
400 }
401 it_logln(UnicodeString("ChoiceFormat format:") + res1);
402 if (res1 != "third") it_errln("*** ChoiceFormat format (Formattable, ...) result!");
403
404 Formattable fta[] = { (int32_t)3 };
405 str = "";
406 fpos = 0;
407 status = U_ZERO_ERROR;
408 res1 = form_pat.format( fta, 1, str, fpos, status );
409 if (!chkstatus( status, "*** test_complex_example format (int32_t, ...)" )) {
410 delete fileform;
411 delete filenumform;
412 delete pattform;
413 return;
414 }
415 it_logln(UnicodeString("ChoiceFormat format:") + res1);
416 if (res1 != "third") it_errln("*** ChoiceFormat format (Formattable[], cnt, ...) result!");
417
418 ParsePosition parse_pos = 0;
419 Formattable result;
420 UnicodeString parsetext("third");
421 form_pat.parse( parsetext, result, parse_pos );
422 double rd = (result.getType() == Formattable::kLong) ? result.getLong() : result.getDouble();
423 if (rd == 3.0) {
424 it_logln("parse( ..., ParsePos ) tested.");
425 }else{
426 it_errln("*** ChoiceFormat parse( ..., ParsePos )!");
427 }
428
429 form_pat.parse( parsetext, result, status );
430 rd = (result.getType() == Formattable::kLong) ? result.getLong() : result.getDouble();
431 if (rd == 3.0) {
432 it_logln("parse( ..., UErrorCode ) tested.");
433 }else{
434 it_errln("*** ChoiceFormat parse( ..., UErrorCode )!");
435 }
436
437 /*
438 UClassID classID = ChoiceFormat::getStaticClassID();
439 if (classID == form_pat.getDynamicClassID()) {
440 it_out << "getStaticClassID and getDynamicClassID tested." << endl;
441 }else{
442 it_errln("*** getStaticClassID and getDynamicClassID!");
443 }
444 */
445
446 it_logln();
447
448 delete fileform;
449 delete filenumform;
450 delete pattform;
451 }
452
453
454 /**
455 * Test new closure API
456 */
457 void TestChoiceFormat::TestClosures(void) {
458 // Construct open, half-open, half-open (the other way), and closed
459 // intervals. Do this both using arrays and using a pattern.
460
461 // 'fmt1' is created using arrays
462 UBool T = TRUE, F = FALSE;
463 // 0: ,1)
464 // 1: [1,2]
465 // 2: (2,3]
466 // 3: (3,4)
467 // 4: [4,5)
468 // 5: [5,
469 double limits[] = { 0, 1, 2, 3, 4, 5 };
470 UBool closures[] = { F, F, T, T, F, F };
471 UnicodeString fmts[] = {
472 ",1)", "[1,2]", "(2,3]", "(3,4)", "[4,5)", "[5,"
473 };
474 ChoiceFormat fmt1(limits, closures, fmts, 6);
475
476 // 'fmt2' is created using a pattern; it should be equivalent
477 UErrorCode status = U_ZERO_ERROR;
478 const char* PAT = "0#,1)|1#[1,2]|2<(2,3]|3<(3,4)|4#[4,5)|5#[5,";
479 ChoiceFormat fmt2(PAT, status);
480 if (U_FAILURE(status)) {
481 errln("FAIL: ChoiceFormat constructor failed");
482 return;
483 }
484
485 // Check the patterns
486 UnicodeString str;
487 fmt1.toPattern(str);
488 if (str == PAT) {
489 logln("Ok: " + str);
490 } else {
491 errln("FAIL: " + str + ", expected " + PAT);
492 }
493 str.truncate(0);
494
495 // Check equality
496 if (fmt1 != fmt2) {
497 errln("FAIL: fmt1 != fmt2");
498 }
499
500 #if 0 // ICU 4.8 deprecates and disables the ChoiceFormat getters.
501 int32_t i;
502 int32_t count2 = 0;
503 const double *limits2 = fmt2.getLimits(count2);
504 const UBool *closures2 = fmt2.getClosures(count2);
505
506 if((count2 != 6) || !limits2 || !closures2) {
507 errln("FAIL: couldn't get limits or closures");
508 } else {
509 for(i=0;i<count2;i++) {
510 logln("#%d/%d: limit %g closed %s\n",
511 i, count2,
512 limits2[i],
513 closures2[i] ?"T":"F");
514 if(limits2[i] != limits[i]) {
515 errln("FAIL: limit #%d = %g, should be %g\n", i, limits2[i], limits[i]);
516 }
517 if((closures2[i]!=0) != (closures[i]!=0)) {
518 errln("FAIL: closure #%d = %s, should be %s\n", i, closures2[i]?"T":"F", closures[i]?"T":"F");
519 }
520 }
521 }
522 #endif
523
524 // Now test both format objects
525 UnicodeString exp[] = {
526 /*-0.5 => */ ",1)",
527 /* 0.0 => */ ",1)",
528 /* 0.5 => */ ",1)",
529 /* 1.0 => */ "[1,2]",
530 /* 1.5 => */ "[1,2]",
531 /* 2.0 => */ "[1,2]",
532 /* 2.5 => */ "(2,3]",
533 /* 3.0 => */ "(2,3]",
534 /* 3.5 => */ "(3,4)",
535 /* 4.0 => */ "[4,5)",
536 /* 4.5 => */ "[4,5)",
537 /* 5.0 => */ "[5,",
538 /* 5.5 => */ "[5,"
539 };
540
541 // Each format object should behave exactly the same
542 ChoiceFormat* FMT[] = { &fmt1, &fmt2 };
543 for (int32_t pass=0; pass<2; ++pass) {
544 int32_t j=0;
545 for (int32_t ix=-5; ix<=55; ix+=5) {
546 double x = ix / 10.0; // -0.5 to 5.5 step +0.5
547 FMT[pass]->format(x, str);
548 if (str == exp[j]) {
549 logln((UnicodeString)"Ok: " + x + " => " + str);
550 } else {
551 errln((UnicodeString)"FAIL: " + x + " => " + str +
552 ", expected " + exp[j]);
553 }
554 str.truncate(0);
555 ++j;
556 }
557 }
558 }
559
560 /**
561 * Helper for TestPatterns()
562 */
563 void TestChoiceFormat::_testPattern(const char* pattern,
564 UBool isValid,
565 double v1, const char* str1,
566 double v2, const char* str2,
567 double v3, const char* str3) {
568 UErrorCode ec = U_ZERO_ERROR;
569 ChoiceFormat fmt(pattern, ec);
570 if (!isValid) {
571 if (U_FAILURE(ec)) {
572 logln((UnicodeString)"Ok: " + pattern + " failed");
573 } else {
574 logln((UnicodeString)"FAIL: " + pattern + " accepted");
575 }
576 return;
577 }
578 if (U_FAILURE(ec)) {
579 errln((UnicodeString)"FAIL: ChoiceFormat(" + pattern + ") failed");
580 return;
581 } else {
582 logln((UnicodeString)"Ok: Pattern: " + pattern);
583 }
584 UnicodeString out;
585 logln((UnicodeString)" toPattern: " + fmt.toPattern(out));
586
587 double v[] = {v1, v2, v3};
588 const char* str[] = {str1, str2, str3};
589 for (int32_t i=0; i<3; ++i) {
590 out.truncate(0);
591 fmt.format(v[i], out);
592 if (out == str[i]) {
593 logln((UnicodeString)"Ok: " + v[i] + " => " + out);
594 } else {
595 errln((UnicodeString)"FAIL: " + v[i] + " => " + out +
596 ", expected " + str[i]);
597 }
598 }
599 }
600
601 /**
602 * Test applyPattern
603 */
604 void TestChoiceFormat::TestPatterns(void) {
605 // Try a pattern that isolates a single value. Create
606 // three ranges: [-Inf,1.0) [1.0,1.0] (1.0,+Inf]
607 _testPattern("0.0#a|1.0#b|1.0<c", TRUE,
608 1.0 - 1e-9, "a",
609 1.0, "b",
610 1.0 + 1e-9, "c");
611
612 #if 0 // ICU 4.8 only checks the pattern syntax, not whether the ranges make sense.
613 // Try an invalid pattern that isolates a single value.
614 // [-Inf,1.0) [1.0,1.0) [1.0,+Inf]
615 _testPattern("0.0#a|1.0#b|1.0#c", FALSE,
616 0, 0, 0, 0, 0, 0);
617
618 // Another
619 // [-Inf,1.0] (1.0,1.0) [1.0,+Inf]
620 _testPattern("0.0#a|1.0<b|1.0#c", FALSE,
621 0, 0, 0, 0, 0, 0);
622 // Another
623 // [-Inf,1.0] (1.0,1.0] (1.0,+Inf]
624 _testPattern("0.0#a|1.0<b|1.0<c", FALSE,
625 0, 0, 0, 0, 0, 0);
626
627 // Try a grossly invalid pattern.
628 // [-Inf,2.0) [2.0,1.0) [1.0,+Inf]
629 _testPattern("0.0#a|2.0#b|1.0#c", FALSE,
630 0, 0, 0, 0, 0, 0);
631 #endif
632 }
633
634 void TestChoiceFormat::TestChoiceFormatToPatternOverflow()
635 {
636 static const double limits[] = {0.1e-78, 1e13, 0.1e78};
637 UnicodeString monthNames[] = { "one", "two", "three" };
638 ChoiceFormat fmt(limits, monthNames, UPRV_LENGTHOF(limits));
639 UnicodeString patStr, expectedPattern1("1e-79#one|10000000000000#two|1e+77#three"),
640 expectedPattern2("1e-079#one|10000000000000#two|1e+077#three");
641 fmt.toPattern(patStr);
642 if (patStr != expectedPattern1 && patStr != expectedPattern2) {
643 errln("ChoiceFormat returned \"" + patStr + "\" instead of \"" + expectedPattern1 + " or " + expectedPattern2 + "\"");
644 }
645 }
646
647 #endif /* #if !UCONFIG_NO_FORMATTING */