Go to the documentation of this file.
16 #include "util/test.h"
17 #include "util/logging.h"
18 #include "util/strutil.h"
19 #include "re2/testing/exhaustive_tester.h"
20 #include "re2/testing/tester.h"
27 DEFINE_bool(show_regexps,
false,
"show regexps during testing");
30 "Stop testing a regular expression after finding this many "
31 "strings that break it.");
39 for (
size_t i = 0;
i < sp.
size();
i++) {
41 LOG(
FATAL) <<
"ExhaustiveTester escape: too long";
42 if(sp[
i] ==
'\\' || sp[
i] ==
'\"') {
45 }
else if(sp[
i] ==
'\n') {
62 for (
int i = 0;
i <
n;
i++) {
82 if (FLAGS_show_regexps) {
83 printf(
"\r%s", regexp.c_str());
91 LOG(
ERROR) <<
"Cannot log with random strings.";
104 RE2 relongest(regexp, longest);
137 if (++bad_inputs >= FLAGS_max_bad_regexp_inputs)
145 const std::vector<std::string>&
alphabet,
146 const std::vector<std::string>&
ops,
148 const std::vector<std::string>& stralphabet,
160 maxstrlen, stralphabet,
wrapper,
164 printf(
"%d regexps, %d tests, %d failures [%d/%d str]\n",
165 t.regexps(), t.tests(), t.failures(), maxstrlen, (
int)stralphabet.size());
175 const char* tops[] = {
"",
"^(?:%s)",
"(?:%s)$",
"^(?:%s)$" };
182 Split(
"", stralphabet),
std::vector< std::string > Split(const StringPiece &sep, const StringPiece &s)
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
void ExhaustiveTest(int maxatoms, int maxops, const std::vector< std::string > &alphabet, const std::vector< std::string > &ops, int maxstrlen, const std::vector< std::string > &stralphabet, const std::string &wrapper, const std::string &topwrapper)
static const char alphabet[]
DEFINE_bool(show_regexps, false, "show regexps during testing")
static void PrintResult(const RE2 &re, const StringPiece &input, RE2::Anchor anchor, StringPiece *m, int n)
DEFINE_int32(max_bad_regexp_inputs, 1, "Stop testing a regular expression after finding this many " "strings that break it.")
bool TestInput(const StringPiece &text)
std::string StringPrintf(const char *format,...)
void Random(int32_t seed, int n)
void EgrepTest(int maxatoms, int maxops, const std::string &alphabet, int maxstrlen, const std::string &stralphabet, const std::string &wrapper)
grpc_channel_wrapper * wrapper
static const LogLevel ERROR
bool Match(const StringPiece &text, size_t startpos, size_t endpos, Anchor re_anchor, StringPiece *submatch, int nsubmatch) const
static const std::vector< std::string > & EgrepOps()
const bool RE2_DEBUG_MODE
void HandleRegexp(const std::string ®exp)
void set_longest_match(bool b)
static char * escape(const StringPiece &sp)
const StringPiece & Next()
int NumberOfCapturingGroups() const
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:20