MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / CorrectCC

Function CorrectCC

extern/re2/re2/testing/charclass_test.cc:140–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138
139template <typename CharClass>
140bool CorrectCC(CharClass *cc, CCTest *t, const char *desc) {
141 typename CharClass::iterator it = cc->begin();
142 int size = 0;
143 for (int j = 0; t->final[j].lo >= 0; j++, ++it) {
144 if (it == cc->end() ||
145 it->lo != t->final[j].lo ||
146 it->hi != t->final[j].hi) {
147 Broke(desc, t, cc);
148 return false;
149 }
150 size += it->hi - it->lo + 1;
151 }
152 if (it != cc->end()) {
153 Broke(desc, t, cc);
154 return false;
155 }
156 if (cc->size() != size) {
157 Broke(desc, t, cc);
158 printf("wrong size: want %d have %d\n", size, cc->size());
159 return false;
160 }
161
162 for (int j = 0; j < 101; j++) {
163 if (j == 100)
164 j = Runemax;
165 if (ShouldContain(t, j) != cc->Contains(j)) {
166 Broke(desc, t, cc);
167 printf("want contains(%d)=%d, got %d\n",
168 j, ShouldContain(t, j), cc->Contains(j));
169 return false;
170 }
171 }
172
173 CharClass* ncc = Negate(cc);
174 for (int j = 0; j < 101; j++) {
175 if (j == 100)
176 j = Runemax;
177 if (ShouldContain(t, j) == ncc->Contains(j)) {
178 Broke(desc, t, cc);
179 Broke("ncc", NULL, ncc);
180 printf("want ncc contains(%d)!=%d, got %d\n",
181 j, ShouldContain(t, j), ncc->Contains(j));
182 Delete(ncc);
183 return false;
184 }
185 if (ncc->size() != Runemax+1 - cc->size()) {
186 Broke(desc, t, cc);
187 Broke("ncc", NULL, ncc);
188 printf("ncc size should be %d is %d\n",
189 Runemax+1 - cc->size(), ncc->size());
190 Delete(ncc);
191 return false;
192 }
193 }
194 Delete(ncc);
195 return true;
196}
197

Callers 1

TESTFunction · 0.85

Calls 8

BrokeFunction · 0.85
ShouldContainFunction · 0.85
NegateFunction · 0.85
DeleteFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected