[clang-format] add a regression test for include sorting

This adds a regression test from the comments
on https://reviews.llvm.org/D121370.

Reviewed By: MyDeveloperDay, curdeius

Differential Revision: https://reviews.llvm.org/D124513
This commit is contained in:
Krasimir Georgiev 2022-04-28 11:01:27 +02:00
parent e8cc7490d2
commit be656df187
1 changed files with 14 additions and 0 deletions

View File

@ -458,6 +458,20 @@ TEST_F(SortIncludesTest, HandlesMultilineIncludes) {
"#include \"b.h\"\n"));
}
TEST_F(SortIncludesTest, HandlesTrailingCommentsWithAngleBrackets) {
// Regression test from the discussion at https://reviews.llvm.org/D121370.
EXPECT_EQ("#include <cstdint>\n"
"\n"
"#include \"util/bar.h\"\n"
"#include \"util/foo/foo.h\" // foo<T>\n",
sort("#include <cstdint>\n"
"\n"
"#include \"util/bar.h\"\n"
"#include \"util/foo/foo.h\" // foo<T>\n",
/*FileName=*/"input.cc",
/*ExpectedNumRanges=*/0));
}
TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
EXPECT_EQ("#include \"llvm/a.h\"\n"