summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2019-03-06 12:47:45 +0100
committerIvan Donchevskii <ivan.donchevskii@qt.io>2019-03-06 14:23:55 +0000
commit35b0b44b21cd24e76455525c25b0b9ab08349233 (patch)
tree3f23899b477ec4e8e8d8d82113515e6037e45034 /tests/unit
parent7236e340a968be964e67ced3f29eadf76787fdcf (diff)
downloadqt-creator-35b0b44b21cd24e76455525c25b0b9ab08349233.tar.gz
ClangFormat: Enable includes sorting
Sort includes only in modes when all replacements are used (manual indentation with "Format instead of indent" selected and saving with "Format on save" activated). Change-Id: I73dfa1d3211760269fe7d33a141f4d831ff65c15 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/unittest/clangformat-test.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unit/unittest/clangformat-test.cpp b/tests/unit/unittest/clangformat-test.cpp
index 5f0aaf1d87..5dbe291b26 100644
--- a/tests/unit/unittest/clangformat-test.cpp
+++ b/tests/unit/unittest/clangformat-test.cpp
@@ -633,6 +633,23 @@ TEST_F(ClangFormat, FormatTemplateparameters)
ASSERT_THAT(documentLines(), ElementsAre("using Alias = Template<A, B, C>"));
}
+
+TEST_F(ClangFormat, SortIncludes)
+{
+ insertLines({"#include \"b.h\"",
+ "#include \"a.h\"",
+ "",
+ "#include <bb.h>",
+ "#include <aa.h>"});
+
+ indenter.format({{1, 5}});
+
+ ASSERT_THAT(documentLines(), ElementsAre("#include \"a.h\"",
+ "#include \"b.h\"",
+ "",
+ "#include <aa.h>",
+ "#include <bb.h>"));
+}
// clang-format on
} // namespace