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

Method TestInstance

extern/re2/re2/testing/tester.cc:185–290  ·  view source on GitHub ↗

Constructs and saves all the matching engines that will be required for the given tests.

Source from the content-addressed store, hash-verified

183// Constructs and saves all the matching engines that
184// will be required for the given tests.
185TestInstance::TestInstance(const StringPiece& regexp_str, Prog::MatchKind kind,
186 Regexp::ParseFlags flags)
187 : regexp_str_(regexp_str),
188 kind_(kind),
189 flags_(flags),
190 error_(false),
191 regexp_(NULL),
192 num_captures_(0),
193 prog_(NULL),
194 rprog_(NULL),
195 re_(NULL),
196 re2_(NULL) {
197
198 VLOG(1) << CEscape(regexp_str);
199
200 // Compile regexp to prog.
201 // Always required - needed for backtracking (reference implementation).
202 RegexpStatus status;
203 regexp_ = Regexp::Parse(regexp_str, flags, &status);
204 if (regexp_ == NULL) {
205 LOG(INFO) << "Cannot parse: " << CEscape(regexp_str_)
206 << " mode: " << FormatMode(flags);
207 error_ = true;
208 return;
209 }
210 num_captures_ = regexp_->NumCaptures();
211 prog_ = regexp_->CompileToProg(0);
212 if (prog_ == NULL) {
213 LOG(INFO) << "Cannot compile: " << CEscape(regexp_str_);
214 error_ = true;
215 return;
216 }
217 if (GetFlag(FLAGS_dump_prog)) {
218 LOG(INFO) << "Prog for "
219 << " regexp "
220 << CEscape(regexp_str_)
221 << " (" << FormatKind(kind_)
222 << ", " << FormatMode(flags_)
223 << ")\n"
224 << prog_->Dump();
225 }
226
227 // Compile regexp to reversed prog. Only needed for DFA engines.
228 if (Engines() & ((1<<kEngineDFA)|(1<<kEngineDFA1))) {
229 rprog_ = regexp_->CompileToReverseProg(0);
230 if (rprog_ == NULL) {
231 LOG(INFO) << "Cannot reverse compile: " << CEscape(regexp_str_);
232 error_ = true;
233 return;
234 }
235 if (GetFlag(FLAGS_dump_rprog))
236 LOG(INFO) << rprog_->Dump();
237 }
238
239 // Create re string that will be used for RE and RE2.
240 std::string re = std::string(regexp_str);
241 // Accomodate flags.
242 // Regexp::Latin1 will be accomodated below.

Callers

nothing calls this directly

Calls 15

CEscapeFunction · 0.85
ParseFunction · 0.85
FormatModeFunction · 0.85
GetFlagFunction · 0.85
FormatKindFunction · 0.85
EnginesFunction · 0.85
NumCapturesMethod · 0.80
CompileToProgMethod · 0.80
CompileToReverseProgMethod · 0.80
set_encodingMethod · 0.80
set_longest_matchMethod · 0.80
MimicsPCREMethod · 0.80

Tested by

no test coverage detected