Skip to content

Commit d1d2932

Browse files
authored
[Support][NFC] Add test documenting that empty Regex pattern matches nothing. (llvm#83849)
I was wondering about this when I recently used `Regex`, and I thought it would be nice to have a test documenting this behavior.
1 parent 49f9505 commit d1d2932

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

llvm/unittests/Support/RegexTest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ TEST_F(RegexTest, Basics) {
6060
EXPECT_TRUE(r5.match(String));
6161
}
6262

63+
TEST_F(RegexTest, EmptyPattern) {
64+
// The empty pattern doesn't match anything -- not even the empty string.
65+
// (This is different from some other regex implementations.)
66+
Regex r("");
67+
EXPECT_FALSE(r.match("123"));
68+
EXPECT_FALSE(r.match(""));
69+
}
70+
6371
TEST_F(RegexTest, Backreferences) {
6472
Regex r1("([a-z]+)_\\1");
6573
SmallVector<StringRef, 4> Matches;

0 commit comments

Comments
 (0)