Go to the documentation of this file.
16 #include "util/test.h"
17 #include "util/flags.h"
18 #include "util/logging.h"
19 #include "util/strutil.h"
20 #include "re2/testing/exhaustive_tester.h"
21 #include "re2/testing/tester.h"
28 DEFINE_FLAG(
bool, show_regexps,
false,
"show regexps during testing");
31 "Stop testing a regular expression after finding this many "
32 "strings that break it.");
40 for (
size_t i = 0;
i < sp.
size();
i++) {
42 LOG(
FATAL) <<
"ExhaustiveTester escape: too long";
43 if(sp[
i] ==
'\\' || sp[
i] ==
'\"') {
46 }
else if(sp[
i] ==
'\n') {
63 for (
int i = 0;
i <
n;
i++) {
85 if (
GetFlag(FLAGS_show_regexps)) {
86 printf(
"\r%s", regexp.c_str());
94 LOG(
ERROR) <<
"Cannot log with random strings.";
105 RE2::Options longest;
106 longest.set_longest_match(
true);
107 RE2 relongest(regexp, longest);
108 int ngroup = re.NumberOfCapturingGroups()+1;
109 StringPiece*
group =
new StringPiece[ngroup];
127 Tester tester(regexp);
140 if (++bad_inputs >=
GetFlag(FLAGS_max_bad_regexp_inputs))
148 const std::vector<std::string>&
alphabet,
149 const std::vector<std::string>&
ops,
151 const std::vector<std::string>& stralphabet,
163 maxstrlen, stralphabet,
wrapper,
167 printf(
"%d regexps, %d tests, %d failures [%d/%d str]\n",
168 t.regexps(),
t.tests(),
t.failures(), maxstrlen, (
int)stralphabet.size());
178 const char* tops[] = {
"",
"^(?:%s)",
"(?:%s)$",
"^(?:%s)$" };
185 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[]
static void PrintResult(const RE2 &re, const StringPiece &input, RE2::Anchor anchor, StringPiece *m, int n)
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)
DEFINE_FLAG(bool, show_regexps, false, "show regexps during testing")
static char * escape(const StringPiece &sp)
const StringPiece & Next()
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:20