diff options
| author | Daniel Jasper <djasper@google.com> | 2014-01-05 12:38:10 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-01-05 12:38:10 +0000 |
| commit | 9697281eecdc8204c53f4be6b778f9e5988a41c8 (patch) | |
| tree | 06b6b0d57047dc0628155422c34a4e09c4b0345c /clang/unittests/Format/FormatTest.cpp | |
| parent | 52e4a0e109dd0428b40ae3b380616cd211b3a705 (diff) | |
| download | bcm5719-llvm-9697281eecdc8204c53f4be6b778f9e5988a41c8.tar.gz bcm5719-llvm-9697281eecdc8204c53f4be6b778f9e5988a41c8.zip | |
clang-format: Allow formatting short enums on a single line.
Before:
enum ShortEnum {
A,
B,
C
};
After:
enum ShortEnum { A, B, C };
This seems to be the predominant choice in LLVM/Clang as well as in
Google style.
llvm-svn: 198558
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 232a0635581..685c9022dad 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1650,18 +1650,21 @@ TEST_F(FormatTest, FormatsEnum) { verifyFormat("enum X f() {\n a();\n return 42;\n}"); verifyFormat("enum {\n" " Bar = Foo<int, int>::value\n" - "};"); + "};", + getLLVMStyleWithColumns(30)); + + verifyFormat("enum ShortEnum { A, B, C };"); } TEST_F(FormatTest, FormatsEnumsWithErrors) { verifyFormat("enum Type {\n" - " One = 0;\n" // These semicolons should be commas. + " One = 0; // These semicolons should be commas.\n" " Two = 1;\n" "};"); verifyFormat("namespace n {\n" "enum Type {\n" " One,\n" - " Two,\n" // missing }; + " Two, // missing };\n" " int i;\n" "}\n" "void g() {}"); @@ -1703,13 +1706,11 @@ TEST_F(FormatTest, FormatsEnumClass) { TEST_F(FormatTest, FormatsEnumTypes) { verifyFormat("enum X : int {\n" - " A,\n" - " B\n" - "};"); - verifyFormat("enum X : std::uint32_t {\n" - " A,\n" + " A, // Force multiple lines.\n" " B\n" "};"); + verifyFormat("enum X : int { A, B };"); + verifyFormat("enum X : std::uint32_t { A, B };"); } TEST_F(FormatTest, FormatsBitfields) { @@ -6605,7 +6606,7 @@ TEST_F(FormatTest, ConfigurableUseOfTab) { "};", Tab); verifyFormat("enum A {\n" - "\ta1,\n" + "\ta1, // Force multiple lines\n" "\ta2,\n" "\ta3\n" "};", |

