mirror of https://github.com/google/benchmark.git
Added more complicated regex test patterns
This commit is contained in:
parent
f043826542
commit
0fd0be9789
|
@ -22,9 +22,49 @@ TEST(Regex, RegexSimple) {
|
|||
EXPECT_FALSE(re.Match(""));
|
||||
EXPECT_TRUE(re.Match("a"));
|
||||
EXPECT_TRUE(re.Match("aa"));
|
||||
EXPECT_TRUE(re.Match("baa"));
|
||||
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) {
|
||||
benchmark::Regex re;
|
||||
EXPECT_FALSE(re.Init("[", NULL));
|
||||
|
|
Loading…
Reference in New Issue