=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/154...@github.com>


================
@@ -15277,6 +15290,123 @@ TEST_F(FormatTest, NeverMergeShortRecords) {
                Style);
 }
 
+TEST_F(FormatTest, AllowShortRecordOnASingleLineNonSplit) {
+  FormatStyle Style = getLLVMStyle();
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.SplitEmptyRecord = false;
----------------
owenca wrote:

`SplitEmptyRecord` is irrelevant if `BreakBeforeBraces` is the default 
`BS_Attach`. Basically, what I was looking for is as follows:
```c++
auto Style = getLLVMStyle();
EXPECT_EQ(Style.AllowShortRecordOnASingleLine, 
FormatStyle::SRS_EmptyIfAttached);
// No need to add test cases for the default.

Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never;
verifyFormat("class foo {\n"
             "};"
             "class bar {\n"
             "  int i;\n"
             "};",
             Style);
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
Style.BraceWraping.AfterClass = true;
verifyFormat("class foo\n"
             "{\n"
             "};"
             "class bar\n"
             "{\n"
             "  int i;\n"
             "};",
             Style);
Style.SplitEmptyRecord = false;
verifyFormat("class foo\n"
             "{};",
             // No need to repeat the non-empty class test case.
             Style);

Style = getLLVMStyle();
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty;
verifyFormat("class foo {};\n"
             "class bar {\n"
             "  int i;\n"
             "};",
             Style);
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
Style.BraceWraping.AfterClass = true;
verifyFormat("class foo {};\n"
             "{\n"
             "};"
             "class bar\n"
             "{\n"
             "  int i;\n"
             "};",
             Style);
Style.SplitEmptyRecord = false;
verifyFormat("class foo {};", Style);

Style = getLLVMStyle();
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always;
verifyFormat("class foo {};\n"
             "class bar { int i; };",
             Style);
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
Style.BraceWraping.AfterClass = true;
verifyFormat("class foo {};\n"
             "{\n"
             "};"
             "class bar { int i; };",
             Style);
Style.SplitEmptyRecord = false;
verifyFormat("class foo {};", Style);
```
You can repeat the above for `struct` and `union`, but IMO it's unnecessary.

https://github.com/llvm/llvm-project/pull/154580
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to