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

Unified Diff: test/cctest/test-regexp.cc

Issue 10975: Case folding mappings (Closed)
Patch Set: Replaced case folding with canonicalization Created 12 years, 1 month 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 | « src/unicode.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-regexp.cc
diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc
index 264dab31fd0e0e09579a48883e56eca905ac1bab..a1cc0e326672fb3a41286a5af6c89599fc1f56cb 100644
--- a/test/cctest/test-regexp.cc
+++ b/test/cctest/test-regexp.cc
@@ -707,6 +707,37 @@ TEST(AddInverseToTable) {
}
+static uc32 canonicalize(uc32 c) {
+ unibrow::uchar canon[unibrow::kMaxMappingSize];
+ int count = unibrow::Ecma262Canonicalize::Convert(c, '\0', canon, NULL);
+ if (count == 0) {
+ return c;
+ } else {
+ CHECK_EQ(1, count);
+ return canon[0];
+ }
+}
+
+
+TEST(LatinCanonicalize) {
+ unibrow::Mapping<unibrow::Ecma262UnCanonicalize> un_canonicalize;
+ for (char lower = 'a'; lower <= 'z'; lower++) {
+ char upper = lower + ('A' - 'a');
Lasse Reichstein 2008/11/17 10:30:42 Would it be reasonable to check every code point i
Christian Plesner Hansen 2008/11/17 10:47:33 Certainly would; I've added it.
+ CHECK_EQ(canonicalize(lower), canonicalize(upper));
+ unibrow::uchar uncanon[unibrow::kMaxMappingSize];
+ int length = un_canonicalize.get(lower, '\0', uncanon);
+ CHECK_EQ(2, length);
+ CHECK_EQ(upper, uncanon[0]);
+ CHECK_EQ(lower, uncanon[1]);
+ }
+ for (uc32 c = 128; c < (1 << 21); c++) {
+ // These exceptions are caused by a known bug in the implementation.
+ if (c != 0x026B && c != 0x027D)
+ CHECK(canonicalize(c) >= 128);
+ }
+}
+
+
TEST(Graph) {
Execute("fo[ob]ar|[ba]z|x[yz]*", "", true);
}
« no previous file with comments | « src/unicode.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698