Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
benchmark
Commits
0fd0be97
Commit
0fd0be97
authored
Jul 31, 2014
by
Matt Clarkson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more complicated regex test patterns
parent
f0438265
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
re_test.cc
test/re_test.cc
+40
-0
No files found.
test/re_test.cc
View file @
0fd0be97
...
@@ -22,9 +22,49 @@ TEST(Regex, RegexSimple) {
...
@@ -22,9 +22,49 @@ TEST(Regex, RegexSimple) {
EXPECT_FALSE
(
re
.
Match
(
""
));
EXPECT_FALSE
(
re
.
Match
(
""
));
EXPECT_TRUE
(
re
.
Match
(
"a"
));
EXPECT_TRUE
(
re
.
Match
(
"a"
));
EXPECT_TRUE
(
re
.
Match
(
"aa"
));
EXPECT_TRUE
(
re
.
Match
(
"aa"
));
EXPECT_TRUE
(
re
.
Match
(
"baa"
));
EXPECT_FALSE
(
re
.
Match
(
"b"
));
EXPECT_FALSE
(
re
.
Match
(
"b"
));
}
}
TEST
(
Regex
,
RegexWildcard
)
{
benchmark
::
Regex
re
;
EXPECT_TRUE
(
re
.
Init
(
"^a*$"
,
NULL
));
EXPECT_TRUE
(
re
.
Match
(
""
));
EXPECT_TRUE
(
re
.
Match
(
"a"
));
EXPECT_TRUE
(
re
.
Match
(
"aa"
));
EXPECT_FALSE
(
re
.
Match
(
"baa"
));
EXPECT_FALSE
(
re
.
Match
(
"b"
));
}
TEST
(
Regex
,
RegexAny
)
{
benchmark
::
Regex
re
;
EXPECT_TRUE
(
re
.
Init
(
"."
,
NULL
));
EXPECT_FALSE
(
re
.
Match
(
""
));
EXPECT_TRUE
(
re
.
Match
(
"a"
));
EXPECT_TRUE
(
re
.
Match
(
"aa"
));
}
TEST
(
Regex
,
RegexExact
)
{
benchmark
::
Regex
re
;
EXPECT_TRUE
(
re
.
Init
(
"^.$"
,
NULL
));
EXPECT_FALSE
(
re
.
Match
(
""
));
EXPECT_TRUE
(
re
.
Match
(
"a"
));
EXPECT_FALSE
(
re
.
Match
(
"aa"
));
}
TEST
(
Regex
,
RegexComplicated
)
{
benchmark
::
Regex
re
;
EXPECT_TRUE
(
re
.
Init
(
"([0-9]+ )?(mon|low)key(s)?"
,
NULL
));
EXPECT_TRUE
(
re
.
Match
(
"something monkey hands"
));
EXPECT_TRUE
(
re
.
Match
(
"1 lowkey"
));
EXPECT_TRUE
(
re
.
Match
(
"19 monkeys"
));
EXPECT_FALSE
(
re
.
Match
(
"09 a"
));
}
TEST
(
Regex
,
InvalidNoErrorMessage
)
{
TEST
(
Regex
,
InvalidNoErrorMessage
)
{
benchmark
::
Regex
re
;
benchmark
::
Regex
re
;
EXPECT_FALSE
(
re
.
Init
(
"["
,
NULL
));
EXPECT_FALSE
(
re
.
Init
(
"["
,
NULL
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment