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

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

Issue 10682: Inverted character classes (Closed)
Patch Set: 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
« src/utils.h ('K') | « src/utils.h ('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 69f637e432ff4bc7aa59a355af91c29f31940cfe..c05fc2359d21b96f7197c1c8b26677b2601aa77e 100644
--- a/test/cctest/test-regexp.cc
+++ b/test/cctest/test-regexp.cc
@@ -438,18 +438,6 @@ TEST(SplayTreeSimple) {
}
-static int CompareChars(const void* ap, const void* bp) {
- uc16 a = *static_cast<const uc16*>(ap);
- uc16 b = *static_cast<const uc16*>(bp);
- if (a < b)
- return -1;
- else if (a > b)
- return 1;
- else
- return 0;
-}
-
-
TEST(DispatchTableConstruction) {
// Initialize test data.
static const int kLimit = 1000;
@@ -457,11 +445,14 @@ TEST(DispatchTableConstruction) {
static const int kRangeSize = 16;
uc16 ranges[kRangeCount][2 * kRangeSize];
for (int i = 0; i < kRangeCount; i++) {
- uc16* range = ranges[i];
+ Vector<uc16> range(ranges[i], 2 * kRangeSize);
for (int j = 0; j < 2 * kRangeSize; j++) {
range[j] = PseudoRandom(i + 25, j + 87) % kLimit;
}
- qsort(range, 2 * kRangeSize, sizeof(uc16), CompareChars);
+ range.Sort();
+ for (int j = 1; j < 2 * kRangeSize; j++) {
+ CHECK(range[j-1] <= range[j]);
+ }
}
// Enter test data into dispatch table.
ZoneScope zone_scope(DELETE_ON_EXIT);
@@ -676,19 +667,29 @@ TEST(MacroAssembler) {
TEST(AddInverseToTable) {
static const int kLimit = 1000;
static const int kRangeCount = 16;
- ZoneScope zone_scope(DELETE_ON_EXIT);
- ZoneList<CharacterRange>* range = new ZoneList<CharacterRange>(kRangeCount);
- for (int i = 0; i < kRangeCount; i++) {
- int from = PseudoRandom(87, i + 25) % kLimit;
- int to = PseudoRandom(i + 87, 25) % (kLimit / 20);
- if (to > kLimit) to = kLimit;
- range->Add(CharacterRange(from, to));
+ for (int t = 0; t < 10; t++) {
+ ZoneScope zone_scope(DELETE_ON_EXIT);
+ ZoneList<CharacterRange>* ranges =
+ new ZoneList<CharacterRange>(kRangeCount);
+ for (int i = 0; i < kRangeCount; i++) {
+ int from = PseudoRandom(t + 87, i + 25) % kLimit;
+ int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20));
+ if (to > kLimit) to = kLimit;
+ ranges->Add(CharacterRange(from, to));
+ }
+ DispatchTable table;
+ CharacterClassNode::AddInverseToTable(ranges, &table, 0);
+ for (int i = 0; i < kLimit; i++) {
+ bool is_on = false;
+ for (int j = 0; !is_on && j < kRangeCount; j++)
+ is_on = ranges->at(j).Contains(i);
+ OutSet* set = table.Get(i);
+ CHECK_EQ(is_on, set->Get(0) == false);
+ }
}
- DispatchTable table;
- // CharacterClassNode::AddInverseToTable(range, &table, 0);
}
TEST(Graph) {
- Execute(".*?a", "", true);
+ Execute(".*?[^a]|b", "", true);
}
« src/utils.h ('K') | « src/utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698