Chromium Code Reviews| 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); |
| } |