summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2013-12-12 02:51:58 +0000
committerAlp Toker <alp@nuanti.com>2013-12-12 02:51:58 +0000
commit22e0e0c1de72187f9f20e9d7375422b51ec10fb9 (patch)
treebf62d97e503d5507cfd501f1538b6a02e276a44a /unittests
parentdcdc5736ad62ad2ba62419e8d311d883cee1a329 (diff)
downloadllvm-22e0e0c1de72187f9f20e9d7375422b51ec10fb9.tar.gz
llvm-22e0e0c1de72187f9f20e9d7375422b51ec10fb9.tar.bz2
llvm-22e0e0c1de72187f9f20e9d7375422b51ec10fb9.tar.xz
Add missing escape characters to the new Regex::escape() function
The old AddFixedStringToRegEx() it was based on got away with this for the longest time, but the problem became easy to spot after the cleanup in r197096. Also add a quick unit test to cover regex escaping. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197121 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Support/RegexTest.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/unittests/Support/RegexTest.cpp b/unittests/Support/RegexTest.cpp
index 7b977f7446..abc8d0f38e 100644
--- a/unittests/Support/RegexTest.cpp
+++ b/unittests/Support/RegexTest.cpp
@@ -127,6 +127,11 @@ TEST_F(RegexTest, IsLiteralERE) {
EXPECT_FALSE(Regex::isLiteralERE("abc{1,2}"));
}
+TEST_F(RegexTest, Escape) {
+ EXPECT_EQ(Regex::escape("a[bc]"), "a\\[bc\\]");
+ EXPECT_EQ(Regex::escape("abc{1\\,2}"), "abc\\{1\\\\,2\\}");
+}
+
TEST_F(RegexTest, IsValid) {
std::string Error;
EXPECT_FALSE(Regex("(foo").isValid(Error));