summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/TrigramIndexTest.cpp
diff options
context:
space:
mode:
authorIvan Krasin <krasin@chromium.org>2016-12-02 23:30:16 +0000
committerIvan Krasin <krasin@chromium.org>2016-12-02 23:30:16 +0000
commit75453b057b6b76889ff3a5bca99f8099c628b389 (patch)
tree623e4ec094e1eab8e5cfe0ed39c1a09c4a1c8578 /llvm/unittests/Support/TrigramIndexTest.cpp
parentcb3ef1561de278ce8819c5a095092dbc2b0d00b2 (diff)
downloadbcm5719-llvm-75453b057b6b76889ff3a5bca99f8099c628b389.tar.gz
bcm5719-llvm-75453b057b6b76889ff3a5bca99f8099c628b389.zip
Support escaping in TrigramIndex.
Summary: This is a follow up to r288303, where I have introduced TrigramIndex to speed up SpecialCaseList for the cases when all rules are simple wildcards, like *hello*wor.d*. Here, I add support for escaping, so that it's possible to specify rules like *c\+\+abi*. Reviewers: pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27318 llvm-svn: 288553
Diffstat (limited to 'llvm/unittests/Support/TrigramIndexTest.cpp')
-rw-r--r--llvm/unittests/Support/TrigramIndexTest.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/llvm/unittests/Support/TrigramIndexTest.cpp b/llvm/unittests/Support/TrigramIndexTest.cpp
index 9f61e7ee4a9..fb0ad1749bb 100644
--- a/llvm/unittests/Support/TrigramIndexTest.cpp
+++ b/llvm/unittests/Support/TrigramIndexTest.cpp
@@ -94,9 +94,29 @@ TEST_F(TrigramIndexTest, TooComplicatedRegex2) {
EXPECT_TRUE(TI->isDefeated());
}
-TEST_F(TrigramIndexTest, SpecialSymbol) {
+TEST_F(TrigramIndexTest, EscapedSymbols) {
std::unique_ptr<TrigramIndex> TI =
- makeTrigramIndex({"*c\\+\\+*"});
+ makeTrigramIndex({"*c\\+\\+*", "*hello\\\\world*", "a\\tb", "a\\0b"});
+ EXPECT_FALSE(TI->isDefeated());
+ EXPECT_FALSE(TI->isDefinitelyOut("c++"));
+ EXPECT_TRUE(TI->isDefinitelyOut("c\\+\\+"));
+ EXPECT_FALSE(TI->isDefinitelyOut("hello\\world"));
+ EXPECT_TRUE(TI->isDefinitelyOut("hello\\\\world"));
+ EXPECT_FALSE(TI->isDefinitelyOut("atb"));
+ EXPECT_TRUE(TI->isDefinitelyOut("a\\tb"));
+ EXPECT_TRUE(TI->isDefinitelyOut("a\tb"));
+ EXPECT_FALSE(TI->isDefinitelyOut("a0b"));
+}
+
+TEST_F(TrigramIndexTest, Backreference1) {
+ std::unique_ptr<TrigramIndex> TI =
+ makeTrigramIndex({"*foo\\1*"});
+ EXPECT_TRUE(TI->isDefeated());
+}
+
+TEST_F(TrigramIndexTest, Backreference2) {
+ std::unique_ptr<TrigramIndex> TI =
+ makeTrigramIndex({"*foo\\2*"});
EXPECT_TRUE(TI->isDefeated());
}
OpenPOWER on IntegriCloud