[clang] [clang-format] clang-format-ignore: Add support for double asterisk patterns (PR #110560)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 2 06:18:28 PDT 2024
================
@@ -164,6 +164,40 @@ TEST_F(MatchFilePathTest, Path) {
EXPECT_FALSE(match("foo\\", R"(foo*\)"));
}
+TEST_F(MatchFilePathTest, DoubleAsterisk) {
+ EXPECT_TRUE(match("a/b/c/d.cpp", "**b**"));
+ EXPECT_TRUE(match("a/b/c/d.cpp", "**/b/**"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**d_*"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/d_*"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**d_**"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/d_**"));
+
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/b/c/**"));
+
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/b/c/d_e.cpp"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/c/d_e.cpp"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/b/**/d_e.cpp"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/b/**/d_e.cpp"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/**/b/**"));
+
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/d"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/b/d"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/b/d/**"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/b/c/"));
+
+ // Multiple consecutive asterisks are treated as **
+ EXPECT_TRUE(match("a/b/c/d.cpp", "***b****"));
+ EXPECT_TRUE(match("a/b/c/d.cpp", "****/b/***"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "***d_**"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "****/d_*"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "***/b/c/*****"));
+
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "*****/d"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "***/b/d"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "*****/b/d/***"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "***/b/c"));
----------------
mydeveloperday wrote:
should there be some tests with repetition?
`project/tests/lib/tests/module/test_abc.cpp`
https://github.com/llvm/llvm-project/pull/110560
More information about the cfe-commits
mailing list