GlobList: added a clear test for pattern priority

Summary:
The last glob that matches the string decides whether that string is
included or excluded.

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66787

llvm-svn: 370028
This commit is contained in:
Dmitri Gribenko 2019-08-27 08:42:42 +00:00
parent e588b8b664
commit fd2315ce21
1 changed files with 35 additions and 1 deletions

View File

@ -31,7 +31,7 @@ TEST(GlobList, Everything) {
EXPECT_TRUE(Filter.contains("*"));
}
TEST(GlobList, Simple) {
TEST(GlobList, OneSimplePattern) {
GlobList Filter("aaa");
EXPECT_TRUE(Filter.contains("aaa"));
@ -41,6 +41,40 @@ TEST(GlobList, Simple) {
EXPECT_FALSE(Filter.contains("bbb"));
}
TEST(GlobList, TwoSimplePatterns) {
GlobList Filter("aaa,bbb");
EXPECT_TRUE(Filter.contains("aaa"));
EXPECT_TRUE(Filter.contains("bbb"));
EXPECT_FALSE(Filter.contains(""));
EXPECT_FALSE(Filter.contains("aa"));
EXPECT_FALSE(Filter.contains("aaaa"));
EXPECT_FALSE(Filter.contains("bbbb"));
}
TEST(GlobList, PatternPriority) {
// The last glob that matches the string decides whether that string is
// included or excluded.
{
GlobList Filter("a*,-aaa");
EXPECT_FALSE(Filter.contains(""));
EXPECT_TRUE(Filter.contains("a"));
EXPECT_TRUE(Filter.contains("aa"));
EXPECT_FALSE(Filter.contains("aaa"));
EXPECT_TRUE(Filter.contains("aaaa"));
}
{
GlobList Filter("-aaa,a*");
EXPECT_FALSE(Filter.contains(""));
EXPECT_TRUE(Filter.contains("a"));
EXPECT_TRUE(Filter.contains("aa"));
EXPECT_TRUE(Filter.contains("aaa"));
EXPECT_TRUE(Filter.contains("aaaa"));
}
}
TEST(GlobList, WhitespacesAtBegin) {
GlobList Filter("-*, a.b.*");