summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-10-18 22:13:25 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-10-18 22:13:25 +0000
commit9da65aa8585ad3d73cb3495bcd018b4e226cac53 (patch)
tree7e7cdcc56a7214914191f97b978e9df818ea390f /clang/unittests/Format/UsingDeclarationsSorterTest.cpp
parent2f27456c826a9266f8f3e9cefafd1f7e08ab51b1 (diff)
downloadbcm5719-llvm-9da65aa8585ad3d73cb3495bcd018b4e226cac53.tar.gz
bcm5719-llvm-9da65aa8585ad3d73cb3495bcd018b4e226cac53.zip
[clang-format] Sort whole block of using declarations while partially formatting
Summary: This patch enables sorting the full block of using declarations when some line is affected. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39024 llvm-svn: 316130
Diffstat (limited to 'clang/unittests/Format/UsingDeclarationsSorterTest.cpp')
-rw-r--r--clang/unittests/Format/UsingDeclarationsSorterTest.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/clang/unittests/Format/UsingDeclarationsSorterTest.cpp b/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
index 219d0302a42..caa2f4380bf 100644
--- a/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
+++ b/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
@@ -291,13 +291,41 @@ TEST_F(UsingDeclarationsSorterTest, SupportsClangFormatOff) {
}
TEST_F(UsingDeclarationsSorterTest, SortsPartialRangeOfUsingDeclarations) {
- EXPECT_EQ("using b;\n"
- "using a;\n"
+ // Sorts the whole block of using declarations surrounding the range.
+ EXPECT_EQ("using a;\n"
+ "using b;\n"
"using c;",
sortUsingDeclarations("using b;\n"
"using c;\n" // starts at offset 10
"using a;",
{tooling::Range(10, 15)}));
+ EXPECT_EQ("using a;\n"
+ "using b;\n"
+ "using c;\n"
+ "using A = b;",
+ sortUsingDeclarations("using b;\n"
+ "using c;\n" // starts at offset 10
+ "using a;\n"
+ "using A = b;",
+ {tooling::Range(10, 15)}));
+
+ EXPECT_EQ("using d;\n"
+ "using c;\n"
+ "\n"
+ "using a;\n"
+ "using b;\n"
+ "\n"
+ "using f;\n"
+ "using e;",
+ sortUsingDeclarations("using d;\n"
+ "using c;\n"
+ "\n"
+ "using b;\n" // starts at offset 19
+ "using a;\n"
+ "\n"
+ "using f;\n"
+ "using e;",
+ {tooling::Range(19, 1)}));
}
} // end namespace
OpenPOWER on IntegriCloud