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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/unicode.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 ranges->Add(CharacterRange(0xFFF0, 0xFFFE)); 700 ranges->Add(CharacterRange(0xFFF0, 0xFFFE));
701 DispatchTable table; 701 DispatchTable table;
702 DispatchTableConstructor cons(&table); 702 DispatchTableConstructor cons(&table);
703 cons.set_choice_index(0); 703 cons.set_choice_index(0);
704 cons.AddInverse(ranges); 704 cons.AddInverse(ranges);
705 CHECK(!table.Get(0xFFFE)->Get(0)); 705 CHECK(!table.Get(0xFFFE)->Get(0));
706 CHECK(table.Get(0xFFFF)->Get(0)); 706 CHECK(table.Get(0xFFFF)->Get(0));
707 } 707 }
708 708
709 709
710 static uc32 canonicalize(uc32 c) {
711 unibrow::uchar canon[unibrow::kMaxMappingSize];
712 int count = unibrow::Ecma262Canonicalize::Convert(c, '\0', canon, NULL);
713 if (count == 0) {
714 return c;
715 } else {
716 CHECK_EQ(1, count);
717 return canon[0];
718 }
719 }
720
721
722 TEST(LatinCanonicalize) {
723 unibrow::Mapping<unibrow::Ecma262UnCanonicalize> un_canonicalize;
724 for (char lower = 'a'; lower <= 'z'; lower++) {
725 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.
726 CHECK_EQ(canonicalize(lower), canonicalize(upper));
727 unibrow::uchar uncanon[unibrow::kMaxMappingSize];
728 int length = un_canonicalize.get(lower, '\0', uncanon);
729 CHECK_EQ(2, length);
730 CHECK_EQ(upper, uncanon[0]);
731 CHECK_EQ(lower, uncanon[1]);
732 }
733 for (uc32 c = 128; c < (1 << 21); c++) {
734 // These exceptions are caused by a known bug in the implementation.
735 if (c != 0x026B && c != 0x027D)
736 CHECK(canonicalize(c) >= 128);
737 }
738 }
739
740
710 TEST(Graph) { 741 TEST(Graph) {
711 Execute("fo[ob]ar|[ba]z|x[yz]*", "", true); 742 Execute("fo[ob]ar|[ba]z|x[yz]*", "", true);
712 } 743 }
OLDNEW
« 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