summaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2019-04-08 23:36:25 +0000
committerOwen Pan <owenpiano@gmail.com>2019-04-08 23:36:25 +0000
commit764bd63e5b6b19051d14a3172ee82fb3e83b8857 (patch)
tree5d9e2b19a57175cdcb7fc08cddfaa0f46bc507e6 /unittests/Format/FormatTest.cpp
parentec5793391fb1c7a72444b844f634d122ad12b2c7 (diff)
downloadclang-764bd63e5b6b19051d14a3172ee82fb3e83b8857.tar.gz
[clang-format] Add AfterCaseLabel to BraceWrapping
Fixes PR38686 llvm-svn: 52527 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@357957 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp50
1 files changed, 36 insertions, 14 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 1839172047..b4605053ea 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1117,6 +1117,7 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
Style.IndentCaseLabels = true;
Style.AllowShortBlocksOnASingleLine = false;
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+ Style.BraceWrapping.AfterCaseLabel = true;
Style.BraceWrapping.AfterControlStatement = true;
EXPECT_EQ("switch (n)\n"
"{\n"
@@ -1138,6 +1139,27 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
" }\n"
"}",
Style));
+ Style.BraceWrapping.AfterCaseLabel = false;
+ EXPECT_EQ("switch (n)\n"
+ "{\n"
+ " case 0: {\n"
+ " return false;\n"
+ " }\n"
+ " default: {\n"
+ " return true;\n"
+ " }\n"
+ "}",
+ format("switch (n) {\n"
+ " case 0:\n"
+ " {\n"
+ " return false;\n"
+ " }\n"
+ " default:\n"
+ " {\n"
+ " return true;\n"
+ " }\n"
+ "}",
+ Style));
}
TEST_F(FormatTest, CaseRanges) {
@@ -1291,6 +1313,7 @@ TEST_F(FormatTest, ShortCaseLabels) {
Style));
Style.AllowShortCaseLabelsOnASingleLine = true;
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+ Style.BraceWrapping.AfterCaseLabel = true;
Style.BraceWrapping.AfterControlStatement = true;
EXPECT_EQ("switch (n)\n"
"{\n"
@@ -11356,6 +11379,7 @@ TEST_F(FormatTest, ParsesConfigurationBools) {
CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
+ CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterCaseLabel);
CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterClass);
CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterControlStatement);
CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterEnum);
@@ -12841,20 +12865,18 @@ TEST_F(FormatTest, ConfigurableContinuationIndentWidth) {
TEST_F(FormatTest, WrappedClosingParenthesisIndent) {
FormatStyle Style = getLLVMStyle();
- verifyFormat(
- "int Foo::getter(\n"
- " //\n"
- ") const {\n"
- " return foo;\n"
- "}",
- Style);
- verifyFormat(
- "void Foo::setter(\n"
- " //\n"
- ") {\n"
- " foo = 1;\n"
- "}",
- Style);
+ verifyFormat("int Foo::getter(\n"
+ " //\n"
+ ") const {\n"
+ " return foo;\n"
+ "}",
+ Style);
+ verifyFormat("void Foo::setter(\n"
+ " //\n"
+ ") {\n"
+ " foo = 1;\n"
+ "}",
+ Style);
}
TEST_F(FormatTest, SpacesInAngles) {