@@ -18,9 +18,7 @@ namespace {
18
18
class FormatTestTextProto : public FormatTestBase {
19
19
protected:
20
20
virtual FormatStyle getDefaultStyle () const override {
21
- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto);
22
- Style.ColumnLimit = 60 ; // To make writing tests easier.
23
- return Style;
21
+ return getTextProtoStyleWithColumns (60 );
24
22
}
25
23
};
26
24
@@ -126,7 +124,8 @@ TEST_F(FormatTestTextProto, ImplicitStringLiteralConcatenation) {
126
124
" 'bbbbb'" );
127
125
verifyFormat (" field_a: \" aaaaa\"\n "
128
126
" \" bbbbb\" " );
129
- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto);
127
+
128
+ auto Style = getDefaultStyle ();
130
129
Style.AlwaysBreakBeforeMultilineStrings = true ;
131
130
verifyFormat (" field_a:\n "
132
131
" 'aaaaa'\n "
@@ -359,46 +358,40 @@ TEST_F(FormatTestTextProto, KeepsCommentsIndentedInList) {
359
358
}
360
359
361
360
TEST_F (FormatTestTextProto, UnderstandsHashComments) {
362
- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto );
363
- Style. ColumnLimit = 60 ; // To make writing tests easier.
364
- EXPECT_EQ (" aaa: 100\n "
365
- " ## this is a double-hash comment.\n "
366
- " bb: 100\n "
367
- " ## another double-hash comment.\n "
368
- " ### a triple-hash comment\n "
369
- " cc: 200\n "
370
- " ### another triple-hash comment\n "
371
- " #### a quadriple-hash comment\n "
372
- " dd: 100\n "
373
- " #### another quadriple-hash comment" ,
374
- format ( " aaa: 100\n "
375
- " ##this is a double-hash comment.\n "
376
- " bb: 100\n "
377
- " ## another double-hash comment.\n "
378
- " ###a triple-hash comment\n "
379
- " cc: 200\n "
380
- " ### another triple-hash comment\n "
381
- " ####a quadriple-hash comment\n "
382
- " dd: 100\n "
383
- " #### another quadriple-hash comment" ,
384
- Style) );
361
+ auto Style = getDefaultStyle ( );
362
+
363
+ verifyFormat (" aaa: 100\n "
364
+ " ## this is a double-hash comment.\n "
365
+ " bb: 100\n "
366
+ " ## another double-hash comment.\n "
367
+ " ### a triple-hash comment\n "
368
+ " cc: 200\n "
369
+ " ### another triple-hash comment\n "
370
+ " #### a quadriple-hash comment\n "
371
+ " dd: 100\n "
372
+ " #### another quadriple-hash comment" ,
373
+ " aaa: 100\n "
374
+ " ##this is a double-hash comment.\n "
375
+ " bb: 100\n "
376
+ " ## another double-hash comment.\n "
377
+ " ###a triple-hash comment\n "
378
+ " cc: 200\n "
379
+ " ### another triple-hash comment\n "
380
+ " ####a quadriple-hash comment\n "
381
+ " dd: 100\n "
382
+ " #### another quadriple-hash comment" ,
383
+ Style);
385
384
386
385
// Ensure we support a common pattern for naming sections.
387
- EXPECT_EQ (" ##############\n "
388
- " # section name\n "
389
- " ##############" ,
390
- format (" ##############\n "
391
- " # section name\n "
392
- " ##############" ,
393
- Style));
394
-
395
- EXPECT_EQ (" ///////////////\n "
396
- " // section name\n "
397
- " ///////////////" ,
398
- format (" ///////////////\n "
399
- " // section name\n "
400
- " ///////////////" ,
401
- Style));
386
+ verifyFormat (" ##############\n "
387
+ " # section name\n "
388
+ " ##############" ,
389
+ Style);
390
+
391
+ verifyFormat (" ///////////////\n "
392
+ " // section name\n "
393
+ " ///////////////" ,
394
+ Style);
402
395
}
403
396
404
397
TEST_F (FormatTestTextProto, FormatsExtensions) {
@@ -519,8 +512,8 @@ TEST_F(FormatTestTextProto, FormatsRepeatedListInitializers) {
519
512
" ]\n "
520
513
" }\n "
521
514
" key: value" );
522
- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto);
523
- Style. ColumnLimit = 60 ; // To make writing tests easier.
515
+
516
+ auto Style = getDefaultStyle ();
524
517
Style.Cpp11BracedListStyle = true ;
525
518
verifyFormat (" keys: [1]" , Style);
526
519
}
@@ -544,7 +537,6 @@ TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) {
544
537
}
545
538
546
539
TEST_F (FormatTestTextProto, PutsMultipleEntriesInExtensionsOnNewlines) {
547
- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto);
548
540
verifyFormat (" pppppppppp: {\n "
549
541
" ssssss: \" http://example.com/blahblahblah\"\n "
550
542
" ppppppp: \" sssss/MMMMMMMMMMMM\"\n "
@@ -556,12 +548,10 @@ TEST_F(FormatTestTextProto, PutsMultipleEntriesInExtensionsOnNewlines) {
556
548
" key: value\n "
557
549
" }\n "
558
550
" }" ,
559
- Style );
551
+ getGoogleStyle (FormatStyle::LK_TextProto) );
560
552
}
561
553
562
554
TEST_F (FormatTestTextProto, BreaksAfterBraceFollowedByClosingBraceOnNextLine) {
563
- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto);
564
- Style.ColumnLimit = 60 ;
565
555
verifyFormat (" keys: [\n "
566
556
" data: { item: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }\n "
567
557
" ]" );
@@ -571,10 +561,6 @@ TEST_F(FormatTestTextProto, BreaksAfterBraceFollowedByClosingBraceOnNextLine) {
571
561
}
572
562
573
563
TEST_F (FormatTestTextProto, BreaksEntriesOfSubmessagesContainingSubmessages) {
574
- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto);
575
- Style.ColumnLimit = 60 ;
576
- // The column limit allows for the keys submessage to be put on 1 line, but we
577
- // break it since it contains a submessage an another entry.
578
564
verifyFormat (" key: valueeeeeeee\n "
579
565
" keys: {\n "
580
566
" item: 'aaaaaaaaaaaaaaaa'\n "
0 commit comments