@@ -8632,19 +8632,6 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
8632
8632
Style);
8633
8633
}
8634
8634
8635
- TEST_F(FormatTest, BreakFunctionsReturningRecords) {
8636
- FormatStyle Style = getLLVMStyle();
8637
- Style.BreakBeforeBraces = FormatStyle::BS_Custom;
8638
- Style.BraceWrapping.AfterFunction = true;
8639
- Style.BraceWrapping.AfterClass = false;
8640
- Style.BraceWrapping.AfterStruct = false;
8641
- Style.BraceWrapping.AfterUnion = false;
8642
-
8643
- verifyFormat("class Bar foo() {}", Style);
8644
- verifyFormat("struct Bar foo() {}", Style);
8645
- verifyFormat("union Bar foo() {}", Style);
8646
- }
8647
-
8648
8635
TEST_F(FormatTest, DontBreakBeforeQualifiedOperator) {
8649
8636
// Regression test for https://bugs.llvm.org/show_bug.cgi?id=40516:
8650
8637
// Prefer keeping `::` followed by `operator` together.
@@ -15347,129 +15334,67 @@ TEST_F(FormatTest, NeverMergeShortRecords) {
15347
15334
Style);
15348
15335
}
15349
15336
15350
- TEST_F(FormatTest, AllowShortRecordOnASingleLineNonSplit ) {
15337
+ TEST_F(FormatTest, AllowShortRecordOnASingleLine ) {
15351
15338
auto Style = getLLVMStyle();
15352
-
15353
- Style.BreakBeforeBraces = FormatStyle::BS_Custom;
15354
- Style.BraceWrapping.SplitEmptyRecord = false;
15339
+ EXPECT_EQ(Style.AllowShortRecordOnASingleLine,
15340
+ FormatStyle::SRS_EmptyIfAttached);
15355
15341
15356
15342
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never;
15357
15343
verifyFormat("class foo {\n"
15358
- " void bar();\n"
15359
- "};",
15360
- Style);
15361
- verifyFormat("class foo {\n"
15362
- "};",
15363
- Style);
15364
-
15365
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_EmptyIfAttached;
15366
- verifyFormat("class foo {\n"
15367
- " void bar();\n"
15368
- "};",
15369
- Style);
15370
- verifyFormat("class foo {};", Style);
15371
-
15372
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty;
15373
- verifyFormat("class foo {\n"
15374
- " void bar();\n"
15344
+ "};\n"
15345
+ "class bar {\n"
15346
+ " int i;\n"
15375
15347
"};",
15376
15348
Style);
15377
- verifyFormat("class foo {};", Style);
15378
-
15379
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always;
15380
- verifyFormat("class foo { void bar(); };", Style);
15381
- verifyFormat("class foo {};", Style);
15382
-
15349
+ Style.BreakBeforeBraces = FormatStyle::BS_Custom;
15383
15350
Style.BraceWrapping.AfterClass = true;
15384
-
15385
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never;
15386
15351
verifyFormat("class foo\n"
15387
15352
"{\n"
15388
- " void bar();\n"
15389
- "};",
15390
- Style);
15391
- verifyFormat("class foo\n{};", Style);
15392
-
15393
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_EmptyIfAttached;
15394
- verifyFormat("class foo\n"
15353
+ "};\n"
15354
+ "class bar\n"
15395
15355
"{\n"
15396
- " void bar() ;\n"
15356
+ " int i ;\n"
15397
15357
"};",
15398
15358
Style);
15399
- verifyFormat("class foo\n{};", Style);
15400
-
15401
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty;
15359
+ Style.BraceWrapping.SplitEmptyRecord = false;
15402
15360
verifyFormat("class foo\n"
15403
- "{\n"
15404
- " void bar();\n"
15405
- "};",
15406
- Style);
15407
- verifyFormat("class foo {};", Style);
15408
-
15409
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always;
15410
- verifyFormat("class foo { void bar(); };", Style);
15411
- verifyFormat("class foo {};", Style);
15412
- }
15413
-
15414
- TEST_F(FormatTest, AllowShortRecordOnASingleLineSplit) {
15415
- auto Style = getLLVMStyle();
15416
-
15417
- EXPECT_EQ(Style.BraceWrapping.SplitEmptyRecord, true);
15418
-
15419
- EXPECT_EQ(Style.AllowShortRecordOnASingleLine,
15420
- FormatStyle::SRS_EmptyIfAttached);
15421
- verifyFormat("class foo {\n"
15422
- " void bar();\n"
15423
- "};",
15424
- Style);
15425
- verifyFormat("class foo {};", Style);
15426
-
15427
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never;
15428
- verifyFormat("class foo {\n"
15429
- " void bar();\n"
15430
- "};",
15431
- Style);
15432
- verifyFormat("class foo {\n"
15433
- "};",
15361
+ "{};",
15434
15362
Style);
15435
15363
15364
+ Style = getLLVMStyle();
15436
15365
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty;
15437
- verifyFormat("class foo {\n"
15438
- " void bar();\n"
15366
+ verifyFormat("class foo {};\n"
15367
+ "class bar {\n"
15368
+ " int i;\n"
15439
15369
"};",
15440
15370
Style);
15441
- verifyFormat("class foo {};", Style);
15442
-
15443
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always;
15444
- verifyFormat("class foo { void bar(); };", Style);
15445
- verifyFormat("class foo {};", Style);
15446
-
15447
15371
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
15448
15372
Style.BraceWrapping.AfterClass = true;
15449
-
15450
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never;
15451
- verifyFormat("class foo\n"
15452
- "{\n"
15453
- "}",
15454
- Style);
15455
-
15456
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_EmptyIfAttached;
15457
15373
verifyFormat("class foo\n"
15458
15374
"{\n"
15459
- "}",
15460
- Style);
15461
-
15462
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty;
15463
- verifyFormat("class foo\n"
15375
+ "};\n"
15376
+ "class bar\n"
15464
15377
"{\n"
15465
- "}",
15378
+ " int i;\n"
15379
+ "};",
15466
15380
Style);
15381
+ Style.BraceWrapping.SplitEmptyRecord = false;
15382
+ verifyFormat("class foo {};", Style);
15467
15383
15384
+ Style = getLLVMStyle();
15468
15385
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always;
15386
+ verifyFormat("class foo {};\n"
15387
+ "class bar { int i; };",
15388
+ Style);
15389
+ Style.BreakBeforeBraces = FormatStyle::BS_Custom;
15390
+ Style.BraceWrapping.AfterClass = true;
15469
15391
verifyFormat("class foo\n"
15470
15392
"{\n"
15471
- "}",
15393
+ "};\n"
15394
+ "class bar { int i; };",
15472
15395
Style);
15396
+ Style.BraceWrapping.SplitEmptyRecord = false;
15397
+ verifyFormat("class foo {};", Style);
15473
15398
}
15474
15399
15475
15400
TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
0 commit comments