summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-11-03 14:38:07 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-11-03 14:38:07 +0000
commitc47fc31da10e8f068902fa8e6f231a358eff9f18 (patch)
tree41d2cc87ac7b152ae78e54194d8086a275e3ada6 /clang/unittests/Format/UsingDeclarationsSorterTest.cpp
parent68797214533e898b1e596a873304e7398d9d4a73 (diff)
downloadbcm5719-llvm-c47fc31da10e8f068902fa8e6f231a358eff9f18.tar.gz
bcm5719-llvm-c47fc31da10e8f068902fa8e6f231a358eff9f18.zip
[clang-format] Sort using-declarations case sensitively with a special case for '_'
Summary: This makes clang-format sort using declarations case-sensitive with the exception that '_' comes just before 'A'. This is better than the current case insensitive version, because it groups uppercase names in the same namespace together. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39549 llvm-svn: 317325
Diffstat (limited to 'clang/unittests/Format/UsingDeclarationsSorterTest.cpp')
-rw-r--r--clang/unittests/Format/UsingDeclarationsSorterTest.cpp55
1 files changed, 12 insertions, 43 deletions
diff --git a/clang/unittests/Format/UsingDeclarationsSorterTest.cpp b/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
index caa2f4380bf..6ce96ed9620 100644
--- a/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
+++ b/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
@@ -86,19 +86,25 @@ TEST_F(UsingDeclarationsSorterTest, SwapsTwoConsecutiveUsingDeclarations) {
"using a, b;"));
}
-TEST_F(UsingDeclarationsSorterTest, SortsCaseInsensitively) {
+TEST_F(UsingDeclarationsSorterTest, SortsCaseSensitively) {
EXPECT_EQ("using A;\n"
"using a;",
sortUsingDeclarations("using A;\n"
"using a;"));
- EXPECT_EQ("using a;\n"
- "using A;",
+ EXPECT_EQ("using A;\n"
+ "using a;",
sortUsingDeclarations("using a;\n"
"using A;"));
- EXPECT_EQ("using a;\n"
- "using B;",
+ EXPECT_EQ("using B;\n"
+ "using a;",
sortUsingDeclarations("using B;\n"
"using a;"));
+
+ // Sorts '_' right before 'A'.
+ EXPECT_EQ("using _;\n"
+ "using A;",
+ sortUsingDeclarations("using A;\n"
+ "using _;"));
EXPECT_EQ("using _;\n"
"using a;",
sortUsingDeclarations("using a;\n"
@@ -110,8 +116,8 @@ TEST_F(UsingDeclarationsSorterTest, SortsCaseInsensitively) {
EXPECT_EQ("using ::testing::_;\n"
"using ::testing::Aardvark;\n"
- "using ::testing::apple::Honeycrisp;\n"
"using ::testing::Xylophone;\n"
+ "using ::testing::apple::Honeycrisp;\n"
"using ::testing::zebra::Stripes;",
sortUsingDeclarations("using ::testing::Aardvark;\n"
"using ::testing::Xylophone;\n"
@@ -120,43 +126,6 @@ TEST_F(UsingDeclarationsSorterTest, SortsCaseInsensitively) {
"using ::testing::zebra::Stripes;"));
}
-TEST_F(UsingDeclarationsSorterTest, SortsStably) {
- EXPECT_EQ("using a;\n"
- "using a;\n"
- "using A;\n"
- "using a;\n"
- "using A;\n"
- "using a;\n"
- "using A;\n"
- "using a;\n"
- "using B;\n"
- "using b;\n"
- "using b;\n"
- "using B;\n"
- "using b;\n"
- "using b;\n"
- "using b;\n"
- "using B;\n"
- "using b;",
- sortUsingDeclarations("using a;\n"
- "using B;\n"
- "using a;\n"
- "using b;\n"
- "using A;\n"
- "using a;\n"
- "using b;\n"
- "using B;\n"
- "using b;\n"
- "using A;\n"
- "using a;\n"
- "using b;\n"
- "using b;\n"
- "using B;\n"
- "using b;\n"
- "using A;\n"
- "using a;"));
-}
-
TEST_F(UsingDeclarationsSorterTest, SortsMultipleTopLevelDeclarations) {
EXPECT_EQ("using a;\n"
"using b;\n"
OpenPOWER on IntegriCloud