2 *******************************************************************************
4 * Copyright (C) 2002, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: cstrcase.c
10 * tab size: 8 (not used)
13 * created on: 2002feb21
14 * created by: Markus W. Scherer
16 * Test file for string casing C API functions.
19 #include "unicode/utypes.h"
20 #include "unicode/uchar.h"
21 #include "unicode/ustring.h"
22 #include "unicode/uloc.h"
23 #include "unicode/ubrk.h"
28 /* test string case mapping functions --------------------------------------- */
34 beforeLower
[]= { 0x61, 0x42, 0x49, 0x3a3, 0xdf, 0x3a3, 0x2f, 0xd93f, 0xdfff },
35 lowerRoot
[]= { 0x61, 0x62, 0x69, 0x3c3, 0xdf, 0x3c2, 0x2f, 0xd93f, 0xdfff },
36 lowerTurkish
[]={ 0x61, 0x62, 0x131, 0x3c3, 0xdf, 0x3c2, 0x2f, 0xd93f, 0xdfff };
42 /* lowercase with root locale and separate buffers */
44 errorCode
=U_ZERO_ERROR
;
45 length
=u_strToLower(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
46 beforeLower
, sizeof(beforeLower
)/U_SIZEOF_UCHAR
,
49 if( U_FAILURE(errorCode
) ||
50 length
!=(sizeof(lowerRoot
)/U_SIZEOF_UCHAR
) ||
51 uprv_memcmp(lowerRoot
, buffer
, length
*U_SIZEOF_UCHAR
)!=0 ||
54 log_err("error in u_strToLower(root locale)=%ld error=%s string matches: %s\t\nlowerRoot=%s\t\nbuffer=%s\n",
56 u_errorName(errorCode
),
57 uprv_memcmp(lowerRoot
, buffer
, length
*U_SIZEOF_UCHAR
)==0 &&
58 buffer
[length
]==0 ? "yes" : "no",
59 aescstrdup(lowerRoot
,-1),
60 aescstrdup(buffer
,-1));
63 /* lowercase with turkish locale and in the same buffer */
64 uprv_memcpy(buffer
, beforeLower
, sizeof(beforeLower
));
65 buffer
[sizeof(beforeLower
)/U_SIZEOF_UCHAR
]=0;
66 errorCode
=U_ZERO_ERROR
;
67 length
=u_strToLower(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
68 buffer
, -1, /* implicit srcLength */
71 if( U_FAILURE(errorCode
) ||
72 length
!=(sizeof(lowerTurkish
)/U_SIZEOF_UCHAR
) ||
73 uprv_memcmp(lowerTurkish
, buffer
, length
*U_SIZEOF_UCHAR
)!=0 ||
76 log_err("error in u_strToLower(turkish locale)=%ld error=%s string matches: %s\n",
78 u_errorName(errorCode
),
79 uprv_memcmp(lowerTurkish
, buffer
, length
*U_SIZEOF_UCHAR
)==0 && buffer
[length
]==0 ? "yes" : "no");
82 /* test preflighting */
83 buffer
[0]=buffer
[2]=0xabcd;
84 errorCode
=U_ZERO_ERROR
;
85 length
=u_strToLower(buffer
, 2, /* set destCapacity=2 */
86 beforeLower
, sizeof(beforeLower
)/U_SIZEOF_UCHAR
,
89 if( errorCode
!=U_BUFFER_OVERFLOW_ERROR
||
90 length
!=(sizeof(lowerRoot
)/U_SIZEOF_UCHAR
) ||
91 uprv_memcmp(lowerRoot
, buffer
, 2*U_SIZEOF_UCHAR
)!=0 ||
94 log_err("error in u_strToLower(root locale preflighting)=%ld error=%s string matches: %s\n",
96 u_errorName(errorCode
),
97 uprv_memcmp(lowerRoot
, buffer
, 2*U_SIZEOF_UCHAR
)==0 && buffer
[2]==0xabcd ? "yes" : "no");
100 /* test error handling */
101 errorCode
=U_ZERO_ERROR
;
102 length
=u_strToLower(NULL
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
103 beforeLower
, sizeof(beforeLower
)/U_SIZEOF_UCHAR
,
106 if(errorCode
!=U_ILLEGAL_ARGUMENT_ERROR
) {
107 log_err("error in u_strToLower(root locale dest=NULL)=%ld error=%s\n",
109 u_errorName(errorCode
));
113 errorCode
=U_ZERO_ERROR
;
114 length
=u_strToLower(buffer
, -1,
115 beforeLower
, sizeof(beforeLower
)/U_SIZEOF_UCHAR
,
118 if( errorCode
!=U_ILLEGAL_ARGUMENT_ERROR
||
121 log_err("error in u_strToLower(root locale destCapacity=-1)=%ld error=%s buffer[0]==0x%lx\n",
123 u_errorName(errorCode
),
132 beforeUpper
[]= { 0x61, 0x42, 0x69, 0x3c2, 0xdf, 0x3c3, 0x2f, 0xfb03, 0xd93f, 0xdfff },
133 upperRoot
[]= { 0x41, 0x42, 0x49, 0x3a3, 0x53, 0x53, 0x3a3, 0x2f, 0x46, 0x46, 0x49, 0xd93f, 0xdfff },
134 upperTurkish
[]={ 0x41, 0x42, 0x130, 0x3a3, 0x53, 0x53, 0x3a3, 0x2f, 0x46, 0x46, 0x49, 0xd93f, 0xdfff };
138 UErrorCode errorCode
;
140 /* uppercase with root locale and in the same buffer */
141 uprv_memcpy(buffer
, beforeUpper
, sizeof(beforeUpper
));
142 errorCode
=U_ZERO_ERROR
;
143 length
=u_strToUpper(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
144 buffer
, sizeof(beforeUpper
)/U_SIZEOF_UCHAR
,
147 if( U_FAILURE(errorCode
) ||
148 length
!=(sizeof(upperRoot
)/U_SIZEOF_UCHAR
) ||
149 uprv_memcmp(upperRoot
, buffer
, length
*U_SIZEOF_UCHAR
)!=0 ||
152 log_err("error in u_strToUpper(root locale)=%ld error=%s string matches: %s\n",
154 u_errorName(errorCode
),
155 uprv_memcmp(upperRoot
, buffer
, length
*U_SIZEOF_UCHAR
)==0 && buffer
[length
]==0 ? "yes" : "no");
158 /* uppercase with turkish locale and separate buffers */
160 errorCode
=U_ZERO_ERROR
;
161 length
=u_strToUpper(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
162 beforeUpper
, sizeof(beforeUpper
)/U_SIZEOF_UCHAR
,
165 if( U_FAILURE(errorCode
) ||
166 length
!=(sizeof(upperTurkish
)/U_SIZEOF_UCHAR
) ||
167 uprv_memcmp(upperTurkish
, buffer
, length
*U_SIZEOF_UCHAR
)!=0 ||
170 log_err("error in u_strToUpper(turkish locale)=%ld error=%s string matches: %s\n",
172 u_errorName(errorCode
),
173 uprv_memcmp(upperTurkish
, buffer
, length
*U_SIZEOF_UCHAR
)==0 && buffer
[length
]==0 ? "yes" : "no");
176 /* test preflighting */
177 errorCode
=U_ZERO_ERROR
;
178 length
=u_strToUpper(NULL
, 0,
179 beforeUpper
, sizeof(beforeUpper
)/U_SIZEOF_UCHAR
,
182 if( errorCode
!=U_BUFFER_OVERFLOW_ERROR
||
183 length
!=(sizeof(upperTurkish
)/U_SIZEOF_UCHAR
)
185 log_err("error in u_strToUpper(turkish locale pure preflighting)=%ld error=%s\n",
187 u_errorName(errorCode
));
190 /* test error handling */
192 errorCode
=U_ZERO_ERROR
;
193 length
=u_strToUpper(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
194 NULL
, sizeof(beforeUpper
)/U_SIZEOF_UCHAR
,
197 if( errorCode
!=U_ILLEGAL_ARGUMENT_ERROR
||
200 log_err("error in u_strToUpper(turkish locale src=NULL)=%ld error=%s buffer[0]==0x%lx\n",
202 u_errorName(errorCode
),
207 errorCode
=U_ZERO_ERROR
;
208 length
=u_strToUpper(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
212 if( errorCode
!=U_ILLEGAL_ARGUMENT_ERROR
||
215 log_err("error in u_strToUpper(turkish locale srcLength=-2)=%ld error=%s buffer[0]==0x%lx\n",
217 u_errorName(errorCode
),
222 #if !UCONFIG_NO_BREAK_ITERATION
228 beforeTitle
[]= { 0x61, 0x42, 0x20, 0x69, 0x3c2, 0x20, 0xdf, 0x3c3, 0x2f, 0xfb03, 0xd93f, 0xdfff },
229 titleWord
[]= { 0x41, 0x62, 0x20, 0x49, 0x3c2, 0x20, 0x53, 0x73, 0x3c3, 0x2f, 0x46, 0x66, 0x69, 0xd93f, 0xdfff },
230 titleChar
[]= { 0x41, 0x42, 0x20, 0x49, 0x3a3, 0x20, 0x53, 0x73, 0x3a3, 0x2f, 0x46, 0x66, 0x69, 0xd93f, 0xdfff };
233 UBreakIterator
*titleIterChars
;
235 UErrorCode errorCode
;
237 errorCode
=U_ZERO_ERROR
;
238 titleIterChars
=ubrk_open(UBRK_CHARACTER
, "", beforeTitle
, sizeof(beforeTitle
)/U_SIZEOF_UCHAR
, &errorCode
);
239 if(U_FAILURE(errorCode
)) {
240 log_err("error: ubrk_open(UBRK_CHARACTER)->%s\n", u_errorName(errorCode
));
244 /* titlecase with standard break iterator and in the same buffer */
245 uprv_memcpy(buffer
, beforeTitle
, sizeof(beforeTitle
));
246 errorCode
=U_ZERO_ERROR
;
247 length
=u_strToTitle(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
248 buffer
, sizeof(beforeTitle
)/U_SIZEOF_UCHAR
,
251 if( U_FAILURE(errorCode
) ||
252 length
!=(sizeof(titleWord
)/U_SIZEOF_UCHAR
) ||
253 uprv_memcmp(titleWord
, buffer
, length
*U_SIZEOF_UCHAR
)!=0 ||
256 log_err("error in u_strToTitle(standard iterator)=%ld error=%s string matches: %s\n",
258 u_errorName(errorCode
),
259 uprv_memcmp(titleWord
, buffer
, length
*U_SIZEOF_UCHAR
)==0 && buffer
[length
]==0 ? "yes" : "no");
262 /* titlecase with UBRK_CHARACTERS and separate buffers */
264 errorCode
=U_ZERO_ERROR
;
265 length
=u_strToTitle(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
266 beforeTitle
, sizeof(beforeTitle
)/U_SIZEOF_UCHAR
,
269 if( U_FAILURE(errorCode
) ||
270 length
!=(sizeof(titleChar
)/U_SIZEOF_UCHAR
) ||
271 uprv_memcmp(titleChar
, buffer
, length
*U_SIZEOF_UCHAR
)!=0 ||
274 log_err("error in u_strToTitle(UBRK_CHARACTERS)=%ld error=%s string matches: %s\n",
276 u_errorName(errorCode
),
277 uprv_memcmp(titleChar
, buffer
, length
*U_SIZEOF_UCHAR
)==0 && buffer
[length
]==0 ? "yes" : "no");
280 /* test preflighting */
281 errorCode
=U_ZERO_ERROR
;
282 length
=u_strToTitle(NULL
, 0,
283 beforeTitle
, sizeof(beforeTitle
)/U_SIZEOF_UCHAR
,
286 if( errorCode
!=U_BUFFER_OVERFLOW_ERROR
||
287 length
!=(sizeof(titleChar
)/U_SIZEOF_UCHAR
)
289 log_err("error in u_strToTitle(UBRK_CHARACTERS pure preflighting)=%ld error=%s\n",
291 u_errorName(errorCode
));
294 /* test error handling */
296 errorCode
=U_ZERO_ERROR
;
297 length
=u_strToTitle(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
298 NULL
, sizeof(beforeTitle
)/U_SIZEOF_UCHAR
,
301 if( errorCode
!=U_ILLEGAL_ARGUMENT_ERROR
||
304 log_err("error in u_strToTitle(UBRK_CHARACTERS src=NULL)=%ld error=%s buffer[0]==0x%lx\n",
306 u_errorName(errorCode
),
311 errorCode
=U_ZERO_ERROR
;
312 length
=u_strToTitle(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
316 if( errorCode
!=U_ILLEGAL_ARGUMENT_ERROR
||
319 log_err("error in u_strToTitle(UBRK_CHARACTERS srcLength=-2)=%ld error=%s buffer[0]==0x%lx\n",
321 u_errorName(errorCode
),
325 ubrk_close(titleIterChars
);
330 /* test case folding and case-insensitive string compare -------------------- */
336 /* input, default, exclude special i */
342 0xfb03, 0xfb03, 0xfb03,
343 0x1040e,0x10436,0x10436,
344 0x5ffff,0x5ffff,0x5ffff
348 mixed
[]= { 0x61, 0x42, 0x130, 0x49, 0x131, 0x3d0, 0xdf, 0xfb03, 0xd93f, 0xdfff },
349 foldedDefault
[]= { 0x61, 0x62, 0x69, 0x307, 0x69, 0x131, 0x3b2, 0x73, 0x73, 0x66, 0x66, 0x69, 0xd93f, 0xdfff },
350 foldedExcludeSpecialI
[]={ 0x61, 0x62, 0x69, 0x131, 0x131, 0x3b2, 0x73, 0x73, 0x66, 0x66, 0x69, 0xd93f, 0xdfff };
352 UVersionInfo unicodeVersion
={ 0, 0, 17, 89 }, unicode_3_1
={ 3, 1, 0, 0 };
359 UErrorCode errorCode
;
362 /* if unicodeVersion()>=3.1 then test exclude-special-i cases as well */
363 u_getUnicodeVersion(unicodeVersion
);
364 isUnicode_3_1
= uprv_memcmp(unicodeVersion
, unicode_3_1
, 4)>=0;
366 /* test simple case folding */
368 for(i
=0; i
<sizeof(simple
)/12; p
+=3, ++i
) {
369 if(u_foldCase(p
[0], U_FOLD_CASE_DEFAULT
)!=p
[1]) {
370 log_err("error: u_foldCase(0x%04lx, default)=0x%04lx instead of 0x%04lx\n",
371 p
[0], u_foldCase(p
[0], U_FOLD_CASE_DEFAULT
), p
[1]);
375 if(isUnicode_3_1
&& u_foldCase(p
[0], U_FOLD_CASE_EXCLUDE_SPECIAL_I
)!=p
[2]) {
376 log_err("error: u_foldCase(0x%04lx, exclude special i)=0x%04lx instead of 0x%04lx\n",
377 p
[0], u_foldCase(p
[0], U_FOLD_CASE_EXCLUDE_SPECIAL_I
), p
[2]);
382 /* test full string case folding with default option and separate buffers */
384 errorCode
=U_ZERO_ERROR
;
385 length
=u_strFoldCase(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
386 mixed
, sizeof(mixed
)/U_SIZEOF_UCHAR
,
389 if( U_FAILURE(errorCode
) ||
390 length
!=(sizeof(foldedDefault
)/U_SIZEOF_UCHAR
) ||
391 uprv_memcmp(foldedDefault
, buffer
, length
*U_SIZEOF_UCHAR
)!=0 ||
394 log_err("error in u_strFoldCase(default)=%ld error=%s string matches: %s\n",
396 u_errorName(errorCode
),
397 uprv_memcmp(foldedDefault
, buffer
, length
*U_SIZEOF_UCHAR
)==0 && buffer
[length
]==0 ? "yes" : "no");
400 /* exclude special i */
403 errorCode
=U_ZERO_ERROR
;
404 length
=u_strFoldCase(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
405 mixed
, sizeof(mixed
)/U_SIZEOF_UCHAR
,
406 U_FOLD_CASE_EXCLUDE_SPECIAL_I
,
408 if( U_FAILURE(errorCode
) ||
409 length
!=(sizeof(foldedExcludeSpecialI
)/U_SIZEOF_UCHAR
) ||
410 uprv_memcmp(foldedExcludeSpecialI
, buffer
, length
*U_SIZEOF_UCHAR
)!=0 ||
413 log_err("error in u_strFoldCase(exclude special i)=%ld error=%s string matches: %s\n",
415 u_errorName(errorCode
),
416 uprv_memcmp(foldedExcludeSpecialI
, buffer
, length
*U_SIZEOF_UCHAR
)==0 && buffer
[length
]==0 ? "yes" : "no");
420 /* test full string case folding with default option and in the same buffer */
421 uprv_memcpy(buffer
, mixed
, sizeof(mixed
));
422 buffer
[sizeof(mixed
)/U_SIZEOF_UCHAR
]=0;
423 errorCode
=U_ZERO_ERROR
;
424 length
=u_strFoldCase(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
425 buffer
, -1, /* implicit srcLength */
428 if( U_FAILURE(errorCode
) ||
429 length
!=(sizeof(foldedDefault
)/U_SIZEOF_UCHAR
) ||
430 uprv_memcmp(foldedDefault
, buffer
, length
*U_SIZEOF_UCHAR
)!=0 ||
433 log_err("error in u_strFoldCase(default same buffer)=%ld error=%s string matches: %s\n",
435 u_errorName(errorCode
),
436 uprv_memcmp(foldedDefault
, buffer
, length
*U_SIZEOF_UCHAR
)==0 && buffer
[length
]==0 ? "yes" : "no");
439 /* test full string case folding, exclude special i, in the same buffer */
441 uprv_memcpy(buffer
, mixed
, sizeof(mixed
));
442 errorCode
=U_ZERO_ERROR
;
443 length
=u_strFoldCase(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
444 buffer
, sizeof(mixed
)/U_SIZEOF_UCHAR
,
445 U_FOLD_CASE_EXCLUDE_SPECIAL_I
,
447 if( U_FAILURE(errorCode
) ||
448 length
!=(sizeof(foldedExcludeSpecialI
)/U_SIZEOF_UCHAR
) ||
449 uprv_memcmp(foldedExcludeSpecialI
, buffer
, length
*U_SIZEOF_UCHAR
)!=0 ||
452 log_err("error in u_strFoldCase(exclude special i same buffer)=%ld error=%s string matches: %s\n",
454 u_errorName(errorCode
),
455 uprv_memcmp(foldedExcludeSpecialI
, buffer
, length
*U_SIZEOF_UCHAR
)==0 && buffer
[length
]==0 ? "yes" : "no");
459 /* test preflighting */
460 buffer
[0]=buffer
[2]=0xabcd;
461 errorCode
=U_ZERO_ERROR
;
462 length
=u_strFoldCase(buffer
, 2, /* set destCapacity=2 */
463 mixed
, sizeof(mixed
)/U_SIZEOF_UCHAR
,
466 if( errorCode
!=U_BUFFER_OVERFLOW_ERROR
||
467 length
!=(sizeof(foldedDefault
)/U_SIZEOF_UCHAR
) ||
468 uprv_memcmp(foldedDefault
, buffer
, 2*U_SIZEOF_UCHAR
)!=0 ||
471 log_err("error in u_strFoldCase(default preflighting)=%ld error=%s string matches: %s\n",
473 u_errorName(errorCode
),
474 uprv_memcmp(foldedDefault
, buffer
, 2*U_SIZEOF_UCHAR
)==0 && buffer
[2]==0xabcd ? "yes" : "no");
477 errorCode
=U_ZERO_ERROR
;
478 length
=u_strFoldCase(NULL
, 0,
479 mixed
, sizeof(mixed
)/U_SIZEOF_UCHAR
,
482 if( errorCode
!=U_BUFFER_OVERFLOW_ERROR
||
483 length
!=(sizeof(foldedDefault
)/U_SIZEOF_UCHAR
)
485 log_err("error in u_strFoldCase(default pure preflighting)=%ld error=%s\n",
487 u_errorName(errorCode
));
490 /* test error handling */
491 errorCode
=U_ZERO_ERROR
;
492 length
=u_strFoldCase(NULL
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
493 mixed
, sizeof(mixed
)/U_SIZEOF_UCHAR
,
496 if(errorCode
!=U_ILLEGAL_ARGUMENT_ERROR
) {
497 log_err("error in u_strFoldCase(default dest=NULL)=%ld error=%s\n",
499 u_errorName(errorCode
));
503 errorCode
=U_ZERO_ERROR
;
504 length
=u_strFoldCase(buffer
, -1,
505 mixed
, sizeof(mixed
)/U_SIZEOF_UCHAR
,
508 if( errorCode
!=U_ILLEGAL_ARGUMENT_ERROR
||
511 log_err("error in u_strFoldCase(default destCapacity=-1)=%ld error=%s buffer[0]==0x%lx\n",
513 u_errorName(errorCode
),
518 errorCode
=U_ZERO_ERROR
;
519 length
=u_strFoldCase(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
520 NULL
, sizeof(mixed
)/U_SIZEOF_UCHAR
,
521 U_FOLD_CASE_EXCLUDE_SPECIAL_I
,
523 if( errorCode
!=U_ILLEGAL_ARGUMENT_ERROR
||
526 log_err("error in u_strFoldCase(exclude special i src=NULL)=%ld error=%s buffer[0]==0x%lx\n",
528 u_errorName(errorCode
),
533 errorCode
=U_ZERO_ERROR
;
534 length
=u_strFoldCase(buffer
, sizeof(buffer
)/U_SIZEOF_UCHAR
,
536 U_FOLD_CASE_EXCLUDE_SPECIAL_I
,
538 if( errorCode
!=U_ILLEGAL_ARGUMENT_ERROR
||
541 log_err("error in u_strFoldCase(exclude special i srcLength=-2)=%ld error=%s buffer[0]==0x%lx\n",
543 u_errorName(errorCode
),
552 mixed
[]= { 0x61, 0x42, 0x131, 0x3a3, 0xdf, 0xfb03, 0xd93f, 0xdfff, 0 },
553 otherDefault
[]= { 0x41, 0x62, 0x131, 0x3c3, 0x73, 0x53, 0x46, 0x66, 0x49, 0xd93f, 0xdfff, 0 },
554 otherExcludeSpecialI
[]={ 0x41, 0x62, 0x131, 0x3c3, 0x53, 0x73, 0x66, 0x46, 0x69, 0xd93f, 0xdfff, 0 },
555 different
[]= { 0x41, 0x62, 0x131, 0x3c3, 0x73, 0x53, 0x46, 0x66, 0x49, 0xd93f, 0xdffd, 0 };
557 UVersionInfo unicodeVersion
={ 0, 0, 17, 89 }, unicode_3_1
={ 3, 1, 0, 0 };
559 int32_t result
, lenMixed
, lenOtherDefault
, lenOtherExcludeSpecialI
, lenDifferent
;
560 UErrorCode errorCode
;
563 errorCode
=U_ZERO_ERROR
;
565 lenMixed
=u_strlen(mixed
);
566 lenOtherDefault
=u_strlen(otherDefault
);
567 lenOtherExcludeSpecialI
=u_strlen(otherExcludeSpecialI
);
568 lenDifferent
=u_strlen(different
);
570 /* if unicodeVersion()>=3.1 then test exclude-special-i cases as well */
571 u_getUnicodeVersion(unicodeVersion
);
572 isUnicode_3_1
= uprv_memcmp(unicodeVersion
, unicode_3_1
, 4)>=0;
574 /* test u_strcasecmp() */
575 result
=u_strcasecmp(mixed
, otherDefault
, U_FOLD_CASE_DEFAULT
);
577 log_err("error: u_strcasecmp(mixed, other, default)=%ld instead of 0\n", result
);
579 result
=u_strCaseCompare(mixed
, -1, otherDefault
, -1, U_FOLD_CASE_DEFAULT
, &errorCode
);
581 log_err("error: u_strCaseCompare(mixed, other, default)=%ld instead of 0\n", result
);
584 /* test u_strcasecmp() - exclude special i */
585 result
=u_strcasecmp(mixed
, otherExcludeSpecialI
, U_FOLD_CASE_EXCLUDE_SPECIAL_I
);
587 log_err("error: u_strcasecmp(mixed, other, exclude special i)=%ld instead of 0\n", result
);
589 result
=u_strCaseCompare(mixed
, lenMixed
, otherExcludeSpecialI
, lenOtherExcludeSpecialI
, U_FOLD_CASE_EXCLUDE_SPECIAL_I
, &errorCode
);
591 log_err("error: u_strCaseCompare(mixed, other, exclude special i)=%ld instead of 0\n", result
);
594 /* test u_strcasecmp() */
595 result
=u_strcasecmp(mixed
, different
, U_FOLD_CASE_DEFAULT
);
597 log_err("error: u_strcasecmp(mixed, different, default)=%ld instead of positive\n", result
);
599 result
=u_strCaseCompare(mixed
, -1, different
, lenDifferent
, U_FOLD_CASE_DEFAULT
, &errorCode
);
601 log_err("error: u_strCaseCompare(mixed, different, default)=%ld instead of positive\n", result
);
604 /* test u_strncasecmp() - stop before the sharp s (U+00df) */
605 result
=u_strncasecmp(mixed
, different
, 4, U_FOLD_CASE_DEFAULT
);
607 log_err("error: u_strncasecmp(mixed, different, 4, default)=%ld instead of 0\n", result
);
609 result
=u_strCaseCompare(mixed
, 4, different
, 4, U_FOLD_CASE_DEFAULT
, &errorCode
);
611 log_err("error: u_strCaseCompare(mixed, 4, different, 4, default)=%ld instead of 0\n", result
);
614 /* test u_strncasecmp() - stop in the middle of the sharp s (U+00df) */
615 result
=u_strncasecmp(mixed
, different
, 5, U_FOLD_CASE_DEFAULT
);
617 log_err("error: u_strncasecmp(mixed, different, 5, default)=%ld instead of positive\n", result
);
619 result
=u_strCaseCompare(mixed
, 5, different
, 5, U_FOLD_CASE_DEFAULT
, &errorCode
);
621 log_err("error: u_strCaseCompare(mixed, 5, different, 5, default)=%ld instead of positive\n", result
);
624 /* test u_memcasecmp() - stop before the sharp s (U+00df) */
625 result
=u_memcasecmp(mixed
, different
, 4, U_FOLD_CASE_DEFAULT
);
627 log_err("error: u_memcasecmp(mixed, different, 4, default)=%ld instead of 0\n", result
);
630 /* test u_memcasecmp() - stop in the middle of the sharp s (U+00df) */
631 result
=u_memcasecmp(mixed
, different
, 5, U_FOLD_CASE_DEFAULT
);
633 log_err("error: u_memcasecmp(mixed, different, 5, default)=%ld instead of positive\n", result
);