Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Unified Diff: source/test/cintltst/cstrcase.c

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/test/cintltst/creststn.c ('k') | source/test/cintltst/cucdapi.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
}
« no previous file with comments | « source/test/cintltst/creststn.c ('k') | source/test/cintltst/cucdapi.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698