@@ -15347,162 +15347,118 @@ TEST_F(FormatTest, NeverMergeShortRecords) {
15347
15347
Style);
15348
15348
}
15349
15349
15350
- TEST_F(FormatTest, AllowShortRecordOnASingleLine ) {
15350
+ TEST_F(FormatTest, AllowShortRecordOnASingleLineNonSplit ) {
15351
15351
FormatStyle Style = getLLVMStyle();
15352
15352
15353
15353
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
15354
15354
Style.BraceWrapping.SplitEmptyRecord = false;
15355
15355
15356
15356
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never;
15357
-
15358
15357
verifyFormat("class foo {\n"
15359
15358
" void bar();\n"
15360
15359
"};",
15361
15360
Style);
15362
15361
verifyFormat("class foo {\n};", Style);
15363
15362
15364
- verifyFormat("struct foo {\n"
15365
- " int bar;\n"
15366
- "};",
15367
- Style);
15368
- verifyFormat("struct foo {\n};", Style);
15369
-
15370
- verifyFormat("union foo {\n"
15371
- " int bar;\n"
15372
- "};",
15373
- Style);
15374
- verifyFormat("union foo {\n};", Style);
15375
-
15376
15363
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_EmptyIfAttached;
15377
-
15378
15364
verifyFormat("class foo {\n"
15379
15365
" void bar();\n"
15380
15366
"};",
15381
15367
Style);
15382
15368
verifyFormat("class foo {};", Style);
15383
15369
15384
- verifyFormat("struct foo {\n"
15385
- " void bar();\n"
15386
- "};",
15387
- Style);
15388
- verifyFormat("struct foo {};", Style);
15389
-
15390
- verifyFormat("union foo {\n"
15391
- " void bar();\n"
15392
- "};",
15393
- Style);
15394
- verifyFormat("union foo {};", Style);
15395
-
15396
15370
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty;
15397
-
15398
15371
verifyFormat("class foo {\n"
15399
15372
" void bar();\n"
15400
15373
"};",
15401
15374
Style);
15402
15375
verifyFormat("class foo {};", Style);
15403
15376
15404
- verifyFormat("struct foo {\n"
15405
- " int bar;\n"
15406
- "};",
15407
- Style);
15408
- verifyFormat("struct foo {};", Style);
15409
-
15410
- verifyFormat("union foo {\n"
15411
- " int bar;\n"
15412
- "};",
15413
- Style);
15414
- verifyFormat("union foo {};", Style);
15415
-
15416
15377
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always;
15417
-
15418
15378
verifyFormat("class foo { void bar(); };", Style);
15419
15379
verifyFormat("class foo {};", Style);
15420
15380
15421
- verifyFormat("struct foo { int bar; };", Style);
15422
- verifyFormat("struct foo {};", Style);
15423
-
15424
- verifyFormat("union foo { int bar; };", Style);
15425
- verifyFormat("union foo {};", Style);
15426
-
15427
15381
Style.BraceWrapping.AfterClass = true;
15428
15382
Style.BraceWrapping.AfterStruct = true;
15429
15383
Style.BraceWrapping.AfterUnion = true;
15430
15384
15431
15385
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never;
15432
-
15433
15386
verifyFormat("class foo\n{\n"
15434
15387
" void bar();\n"
15435
15388
"};",
15436
15389
Style);
15437
15390
verifyFormat("class foo\n{};", Style);
15438
15391
15439
- verifyFormat("struct foo\n{\n"
15440
- " int bar;\n"
15441
- "};",
15442
- Style);
15443
- verifyFormat("struct foo\n{};", Style);
15444
-
15445
- verifyFormat("union foo\n{\n"
15446
- " int bar;\n"
15447
- "};",
15448
- Style);
15449
- verifyFormat("union foo\n{};", Style);
15450
-
15451
15392
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_EmptyIfAttached;
15452
-
15453
15393
verifyFormat("class foo\n{\n"
15454
15394
" void bar();\n"
15455
15395
"};",
15456
15396
Style);
15457
15397
verifyFormat("class foo\n{};", Style);
15458
15398
15459
- verifyFormat("struct foo\n{\n"
15399
+ Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty;
15400
+ verifyFormat("class foo\n{\n"
15460
15401
" void bar();\n"
15461
15402
"};",
15462
15403
Style);
15463
- verifyFormat("struct foo\n {};", Style);
15404
+ verifyFormat("class foo {};", Style);
15464
15405
15465
- verifyFormat("union foo\n{\n"
15466
- " void bar();\n"
15467
- "};",
15468
- Style);
15469
- verifyFormat("union foo\n{};", Style);
15406
+ Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always;
15407
+ verifyFormat("class foo { void bar(); };", Style);
15408
+ verifyFormat("class foo {};", Style);
15409
+ }
15470
15410
15471
- Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty;
15411
+ TEST_F(FormatTest, AllowShortRecordOnASingleLineSplit) {
15412
+ FormatStyle Style = getLLVMStyle();
15472
15413
15473
- verifyFormat("class foo\n{\n"
15414
+ Style.BreakBeforeBraces = FormatStyle::BS_Custom;
15415
+ Style.BraceWrapping.SplitEmptyRecord = true;
15416
+
15417
+ Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never;
15418
+ verifyFormat("class foo {\n"
15474
15419
" void bar();\n"
15475
15420
"};",
15476
15421
Style);
15477
- verifyFormat("class foo {};", Style);
15422
+ verifyFormat("class foo {\n };", Style);
15478
15423
15479
- verifyFormat("struct foo\n{\n"
15480
- " int bar;\n"
15424
+ Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_EmptyIfAttached;
15425
+ verifyFormat("class foo {\n"
15426
+ " void bar();\n"
15481
15427
"};",
15482
15428
Style);
15483
- verifyFormat("struct foo {};", Style);
15429
+ verifyFormat("class foo {};", Style);
15484
15430
15485
- verifyFormat("union foo\n{\n"
15486
- " int bar;\n"
15431
+ Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty;
15432
+ verifyFormat("class foo {\n"
15433
+ " void bar();\n"
15487
15434
"};",
15488
15435
Style);
15489
- verifyFormat("union foo {};", Style);
15436
+ verifyFormat("class foo {};", Style);
15490
15437
15491
15438
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always;
15492
-
15493
15439
verifyFormat("class foo { void bar(); };", Style);
15494
15440
verifyFormat("class foo {};", Style);
15495
15441
15496
- verifyFormat("struct foo { int bar; };", Style);
15497
- verifyFormat("struct foo {};", Style);
15442
+ Style.BraceWrapping.AfterClass = true;
15443
+ Style.BraceWrapping.AfterStruct = true;
15444
+ Style.BraceWrapping.AfterUnion = true;
15445
+
15446
+ Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Never;
15447
+ verifyFormat("class foo\n{\n}", Style);
15448
+ verifyFormat("struct foo\n{\n}", Style);
15449
+ verifyFormat("union foo\n{\n}", Style);
15498
15450
15499
- verifyFormat("union foo { int bar; };", Style);
15500
- verifyFormat("union foo {};", Style);
15451
+ Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_EmptyIfAttached;
15452
+ verifyFormat("class foo\n{\n}", Style);
15453
+ verifyFormat("struct foo\n{\n}", Style);
15454
+ verifyFormat("union foo\n{\n}", Style);
15501
15455
15502
- // Ensure option gets overriden by SplitEmptyRecord
15503
15456
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Empty;
15504
- Style.BraceWrapping.SplitEmptyRecord = true;
15457
+ verifyFormat("class foo\n{\n}", Style);
15458
+ verifyFormat("struct foo\n{\n}", Style);
15459
+ verifyFormat("union foo\n{\n}", Style);
15505
15460
15461
+ Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always;
15506
15462
verifyFormat("class foo\n{\n}", Style);
15507
15463
verifyFormat("struct foo\n{\n}", Style);
15508
15464
verifyFormat("union foo\n{\n}", Style);
0 commit comments