| Index: source/test/cintltst/cstrcase.c
|
| diff --git a/source/test/cintltst/cstrcase.c b/source/test/cintltst/cstrcase.c
|
| index 4f6463012a3ad5fa4dbfea54d3b0348d5f378db6..5f7a6e3114fbb49e05980b72ce9f7e3e25ee65b9 100644
|
| --- a/source/test/cintltst/cstrcase.c
|
| +++ b/source/test/cintltst/cstrcase.c
|
| @@ -1,7 +1,7 @@
|
| /*
|
| *******************************************************************************
|
| *
|
| -* Copyright (C) 2002-2014, International Business Machines
|
| +* Copyright (C) 2002-2015, International Business Machines
|
| * Corporation and others. All Rights Reserved.
|
| *
|
| *******************************************************************************
|
| @@ -25,6 +25,7 @@
|
| #include "unicode/ucasemap.h"
|
| #include "cmemory.h"
|
| #include "cintltst.h"
|
| +#include "ustr_imp.h"
|
|
|
| /* test string case mapping functions --------------------------------------- */
|
|
|
| @@ -989,6 +990,49 @@ TestUCaseMapToTitle(void) {
|
|
|
| #endif
|
|
|
| +/* Test case for internal API u_caseInsensitivePrefixMatch */
|
| +static void
|
| +TestUCaseInsensitivePrefixMatch(void) {
|
| + struct {
|
| + const char *s1;
|
| + const char *s2;
|
| + int32_t r1;
|
| + int32_t r2;
|
| + } testCases[] = {
|
| + {"ABC", "ab", 2, 2},
|
| + {"ABCD", "abcx", 3, 3},
|
| + {"ABC", "xyz", 0, 0},
|
| + /* U+00DF LATIN SMALL LETTER SHARP S */
|
| + {"A\\u00dfBC", "Ass", 2, 3},
|
| + {"Fust", "Fu\\u00dfball", 2, 2},
|
| + {"\\u00dfsA", "s\\u00dfB", 2, 2},
|
| + {"\\u00dfs", "s\\u00df", 2, 2},
|
| + /* U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE */
|
| + {"XYZ\\u0130i\\u0307xxx", "xyzi\\u0307\\u0130yyy", 6, 6},
|
| + {0, 0, 0, 0}
|
| + };
|
| + int32_t i;
|
| +
|
| + for (i = 0; testCases[i].s1 != 0; i++) {
|
| + UErrorCode sts = U_ZERO_ERROR;
|
| + UChar u1[64], u2[64];
|
| + int32_t matchLen1, matchLen2;
|
| +
|
| + u_unescape(testCases[i].s1, u1, 64);
|
| + u_unescape(testCases[i].s2, u2, 64);
|
| +
|
| + u_caseInsensitivePrefixMatch(u1, -1, u2, -1, 0, &matchLen1, &matchLen2, &sts);
|
| + if (U_FAILURE(sts)) {
|
| + log_err("error: %s, s1=%s, s2=%s", u_errorName(sts), testCases[i].s1, testCases[i].s2);
|
| + } else if (matchLen1 != testCases[i].r1 || matchLen2 != testCases[i].r2) {
|
| + log_err("s1=%s, s2=%2 / match len1=%d, len2=%d / expected len1=%d, len2=%d",
|
| + testCases[i].s1, testCases[i].s2,
|
| + matchLen1, matchLen2,
|
| + testCases[i].r1, testCases[i].r2);
|
| + }
|
| + }
|
| +}
|
| +
|
| void addCaseTest(TestNode** root);
|
|
|
| void addCaseTest(TestNode** root) {
|
| @@ -1005,4 +1049,5 @@ void addCaseTest(TestNode** root) {
|
| #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO
|
| addTest(root, &TestUCaseMapToTitle, "tsutil/cstrcase/TestUCaseMapToTitle");
|
| #endif
|
| + addTest(root, &TestUCaseInsensitivePrefixMatch, "tsutil/cstrcase/TestUCaseInsensitivePrefixMatch");
|
| }
|
|
|