diff options
| author | Owen Pan <owenpiano@gmail.com> | 2018-09-21 03:46:36 +0000 |
|---|---|---|
| committer | Owen Pan <owenpiano@gmail.com> | 2018-09-21 03:46:36 +0000 |
| commit | 9da65a3ab009ca2f3b55d7a95d266554fec88d31 (patch) | |
| tree | 89f87e5d4813830624b9a8c052e2bbe31438f32a /clang/unittests/Format/FormatTest.cpp | |
| parent | 1dcce6c92602ef5f2ba69f7f0a2ad7316754216b (diff) | |
| download | bcm5719-llvm-9da65a3ab009ca2f3b55d7a95d266554fec88d31.tar.gz bcm5719-llvm-9da65a3ab009ca2f3b55d7a95d266554fec88d31.zip | |
[clang-format] Do not merge short case labels if followed by a block.
Do not allow short case labels on a single line if the label is followed by a
left brace.
Fixes PR38926.
llvm-svn: 342708
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index db2e226a30e..dac8497c1e6 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1241,6 +1241,30 @@ TEST_F(FormatTest, ShortCaseLabels) { " return false;\n" "}", Style)); + Style.AllowShortCaseLabelsOnASingleLine = true; + Style.BreakBeforeBraces = FormatStyle::BS_Custom; + Style.BraceWrapping.AfterControlStatement = true; + EXPECT_EQ("switch (n)\n" + "{\n" + " case 0:\n" + " {\n" + " return false;\n" + " }\n" + " default:\n" + " {\n" + " return true;\n" + " }\n" + "}", + format("switch (n) {\n" + " case 0: {\n" + " return false;\n" + " }\n" + " default:\n" + " {\n" + " return true;\n" + " }\n" + "}", + Style)); } TEST_F(FormatTest, FormatsLabels) { |

