=?utf-8?q?Tom=C3=A1=C5=A1?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tom=C3=A1=C5=A1?= 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; + + Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never; + verifyFormat("class foo {\n" + " void bar();\n" + "};", + Style); + verifyFormat("class foo {\n};", Style); + + Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_EmptyIfAttached; + verifyFormat("class foo {\n" + " void bar();\n" + "};", + Style); + verifyFormat("class foo {};", Style); + + Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty; + verifyFormat("class foo {\n" + " void bar();\n" + "};", + Style); + verifyFormat("class foo {};", Style); + + Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always; + verifyFormat("class foo { void bar(); };", Style); + verifyFormat("class foo {};", Style); + + Style.BraceWrapping.AfterClass = true; + Style.BraceWrapping.AfterStruct = true; + Style.BraceWrapping.AfterUnion = true; + + Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never; + verifyFormat("class foo\n{\n" + " void bar();\n" + "};", + Style); + verifyFormat("class foo\n{};", Style); + + Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_EmptyIfAttached; + verifyFormat("class foo\n{\n" + " void bar();\n" + "};", + Style); + verifyFormat("class foo\n{};", Style); + + Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty; + verifyFormat("class foo\n{\n" + " void bar();\n" + "};", + Style); + verifyFormat("class foo {};", Style); + + Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always; + verifyFormat("class foo { void bar(); };", Style); + verifyFormat("class foo {};", Style); +} + +TEST_F(FormatTest, AllowShortRecordOnASingleLineSplit) { + FormatStyle Style = getLLVMStyle(); + + Style.BreakBeforeBraces = FormatStyle::BS_Custom; + Style.BraceWrapping.SplitEmptyRecord = true; + + Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never; + verifyFormat("class foo {\n" + " void bar();\n" + "};", + Style); + verifyFormat("class foo {\n};", Style); + + Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_EmptyIfAttached; + verifyFormat("class foo {\n" + " void bar();\n" + "};", + Style); + verifyFormat("class foo {};", Style); ---------------- owenca wrote: Move them up and delete the redundant assignment. 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