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

Krasimir Georgiev via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 28 02:02:49 PDT 2022


Author: Krasimir Georgiev
Date: 2022-04-28T11:02:14+02:00
New Revision: be656df18721dc55a1de2eea64a3f73b6afa29a2

URL: https://github.com/llvm/llvm-project/commit/be656df18721dc55a1de2eea64a3f73b6afa29a2
DIFF: https://github.com/llvm/llvm-project/commit/be656df18721dc55a1de2eea64a3f73b6afa29a2.diff

LOG: [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

Added: 
    

Modified: 
    clang/unittests/Format/SortIncludesTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Format/SortIncludesTest.cpp b/clang/unittests/Format/SortIncludesTest.cpp
index 7becb906d5d5..97a494a0a467 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -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"


        


More information about the cfe-commits mailing list