Go to the documentation of this file.
10 #include "util/test.h"
11 #include "util/flags.h"
12 #include "util/logging.h"
14 #include "util/strutil.h"
17 #include "re2/regexp.h"
18 #include "re2/testing/regexp_generator.h"
19 #include "re2/testing/string_generator.h"
50 TEST(Multithreaded, BuildEntireDFA) {
53 for (
int i = 0;
i <
GetFlag(FLAGS_size);
i++)
61 Prog*
prog = re->CompileToProg(0);
71 for (
int i = 0;
i <
GetFlag(FLAGS_repeat);
i++) {
72 Prog*
prog = re->CompileToProg(0);
75 std::vector<std::thread>
threads;
76 for (
int j = 0;
j <
GetFlag(FLAGS_threads);
j++)
78 for (
int j = 0;
j <
GetFlag(FLAGS_threads);
j++)
92 TEST(SingleThreaded, BuildEntireDFA) {
97 for (
int i = 17;
i < 24;
i++) {
103 Prog*
prog = re->CompileToProg(limit);
170 Prog*
prog = re->CompileToProg(1<<n);
172 for (
int i = 0;
i < 10;
i++) {
173 bool matched =
false;
185 peak_usage =
m.PeakHeapGrowth();
206 for (
int i = 0;
i < 2;
i++) {
207 bool matched =
false;
235 Prog*
prog = re->CompileToProg(1<<n);
246 for (
int i = 0;
i <
GetFlag(FLAGS_repeat);
i++) {
247 Prog*
prog = re->CompileToProg(1<<n);
250 std::vector<std::thread>
threads;
251 for (
int j = 0;
j <
GetFlag(FLAGS_threads);
j++)
253 for (
int j = 0;
j <
GetFlag(FLAGS_threads);
j++)
276 {
"\\A(a|b)",
"abc",
true },
277 {
"(a|b)\\z",
"cba",
true },
278 {
"\\A(a|b)",
"cba",
false },
279 {
"(a|b)\\z",
"abc",
false },
282 TEST(DFA, ReverseMatch) {
288 Prog*
prog = re->CompileToReverseProg(0);
293 if (matched !=
t.match) {
294 LOG(
ERROR) <<
t.regexp <<
" on " <<
t.text <<
": want " <<
t.match;
303 struct CallbackTest {
325 {
"\\Aa\\z",
"[-1,1,-1] [-1,-1,2] [[-1,-1,-1]]" },
326 {
"\\Aab\\z",
"[-1,1,-1,-1] [-1,-1,2,-1] [-1,-1,-1,3] [[-1,-1,-1,-1]]" },
327 {
"\\Aa*b\\z",
"[-1,0,1,-1] [-1,-1,-1,2] [[-1,-1,-1,-1]]" },
328 {
"\\Aa+b\\z",
"[-1,1,-1,-1] [-1,1,2,-1] [-1,-1,-1,3] [[-1,-1,-1,-1]]" },
329 {
"\\Aa?b\\z",
"[-1,1,2,-1] [-1,-1,2,-1] [-1,-1,-1,3] [[-1,-1,-1,-1]]" },
330 {
"\\Aa\\C*\\z",
"[-1,1,-1] [1,1,2] [[-1,-1,-1]]" },
331 {
"\\Aa\\C*",
"[-1,1,-1] [2,2,3] [[2,2,2]] [[-1,-1,-1]]" },
332 {
"a\\C*",
"[0,1,-1] [2,2,3] [[2,2,2]] [[-1,-1,-1]]" },
333 {
"\\C*",
"[1,2] [[1,1]] [[-1,-1]]" },
334 {
"a",
"[0,1,-1] [2,2,2] [[-1,-1,-1]]"} ,
337 TEST(DFA, Callback) {
343 Prog*
prog = re->CompileToProg(0);
350 dump +=
match ?
"[[" :
"[";
351 for (
int b = 0;
b <
prog->bytemap_range() + 1;
b++)
354 dump +=
match ?
"]]" :
"]";
356 if (dump !=
t.dump) {
357 LOG(
ERROR) <<
t.regexp <<
" bytemap:\n" <<
prog->DumpByteMap();
358 LOG(
ERROR) <<
t.regexp <<
" dump:\ngot " << dump <<
"\nwant " <<
t.dump;
static void DoSearch(Prog *prog, const StringPiece &match, const StringPiece &no_match)
static const bool UsingMallocCounter
ReverseTest reverse_tests[]
unsigned char match[65280+2]
static int search_failures
static uv_thread_t * threads
#define ASSERT_LT(val1, val2)
std::string StringPrintf(const char *format,...)
static Regexp * Parse(const StringPiece &s, ParseFlags flags, RegexpStatus *status)
static const LogLevel ERROR
static std::string DeBruijnString(int n)
static int state_cache_resets
static void DoBuild(Prog *prog)
CallbackTest callback_tests[]
AllocList * next[kMaxLevel]
#define ASSERT_TRUE(condition)
#define ASSERT_FALSE(condition)
struct re2::SetHooks set_hooks
static const int THIS_THREAD_ONLY
TEST(TestCharClassBuilder, Adds)
#define ASSERT_GT(val1, val2)
static void TESTING_ONLY_set_dfa_should_bail_when_slow(bool b)
DEFINE_FLAG(int, size, 8, "log2(number of DFA nodes)")
static uv_thread_t thread
#define ASSERT_EQ(val1, val2)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:16