grpc
third_party
bloaty
third_party
re2
re2
testing
bloaty/third_party/re2/re2/testing/exhaustive1_test.cc
Go to the documentation of this file.
1
// Copyright 2008 The RE2 Authors. All Rights Reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
5
// Exhaustive testing of regular expression matching.
6
7
#include <string>
8
#include <vector>
9
10
#include "util/test.h"
11
#include "re2/testing/exhaustive_tester.h"
12
13
DECLARE_string
(regexp_engines);
14
15
namespace
re2
{
16
17
// Test simple repetition operators
18
TEST
(Repetition, Simple) {
19
std::vector<std::string>
ops
=
Split
(
" "
,
20
"%s{0} %s{0,} %s{1} %s{1,} %s{0,1} %s{0,2} "
21
"%s{1,2} %s{2} %s{2,} %s{3,4} %s{4,5} "
22
"%s* %s+ %s? %s*? %s+? %s??"
);
23
ExhaustiveTest
(3, 2,
Explode
(
"abc."
),
ops
,
24
6,
Explode
(
"ab"
),
"(?:%s)"
,
""
);
25
ExhaustiveTest
(3, 2,
Explode
(
"abc."
),
ops
,
26
40,
Explode
(
"a"
),
"(?:%s)"
,
""
);
27
}
28
29
// Test capturing parens -- (a) -- inside repetition operators
30
TEST
(Repetition, Capturing) {
31
std::vector<std::string>
ops
=
Split
(
" "
,
32
"%s{0} %s{0,} %s{1} %s{1,} %s{0,1} %s{0,2} "
33
"%s{1,2} %s{2} %s{2,} %s{3,4} %s{4,5} "
34
"%s* %s+ %s? %s*? %s+? %s??"
);
35
ExhaustiveTest
(3, 2,
Split
(
" "
,
"a (a) b"
),
ops
,
36
7,
Explode
(
"ab"
),
"(?:%s)"
,
""
);
37
38
// This would be a great test, but it runs forever when PCRE is enabled.
39
if
(FLAGS_regexp_engines.find(
"PCRE"
) == std::string::npos)
40
ExhaustiveTest
(3, 2,
Split
(
" "
,
"a (a)"
),
ops
,
41
50,
Explode
(
"a"
),
"(?:%s)"
,
""
);
42
}
43
44
}
// namespace re2
re2::Split
std::vector< std::string > Split(const StringPiece &sep, const StringPiece &s)
Definition:
bloaty/third_party/re2/re2/testing/regexp_generator.cc:256
re2::ExhaustiveTest
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)
Definition:
bloaty/third_party/re2/re2/testing/exhaustive_tester.cc:144
re2
Definition:
bloaty/third_party/re2/re2/bitmap256.h:17
re2::Explode
std::vector< std::string > Explode(const StringPiece &s)
Definition:
bloaty/third_party/re2/re2/testing/regexp_generator.cc:241
DECLARE_string
DECLARE_string(regexp_engines)
re2::TEST
TEST(TestCharClassBuilder, Adds)
Definition:
bloaty/third_party/re2/re2/testing/charclass_test.cc:198
ops
static grpc_op ops[6]
Definition:
test/core/fling/client.cc:39
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:20