Skip to content

Commit be656df

Browse files
committed
[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
1 parent e8cc749 commit be656df

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

clang/unittests/Format/SortIncludesTest.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,20 @@ TEST_F(SortIncludesTest, HandlesMultilineIncludes) {
458458
"#include \"b.h\"\n"));
459459
}
460460

461+
TEST_F(SortIncludesTest, HandlesTrailingCommentsWithAngleBrackets) {
462+
// Regression test from the discussion at https://reviews.llvm.org/D121370.
463+
EXPECT_EQ("#include <cstdint>\n"
464+
"\n"
465+
"#include \"util/bar.h\"\n"
466+
"#include \"util/foo/foo.h\" // foo<T>\n",
467+
sort("#include <cstdint>\n"
468+
"\n"
469+
"#include \"util/bar.h\"\n"
470+
"#include \"util/foo/foo.h\" // foo<T>\n",
471+
/*FileName=*/"input.cc",
472+
/*ExpectedNumRanges=*/0));
473+
}
474+
461475
TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
462476
Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
463477
EXPECT_EQ("#include \"llvm/a.h\"\n"

0 commit comments

Comments
 (0)