@@ -18,9 +18,7 @@ namespace {
1818class FormatTestTextProto : public FormatTestBase {
1919protected:
2020 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 );
2422 }
2523};
2624
@@ -126,7 +124,8 @@ TEST_F(FormatTestTextProto, ImplicitStringLiteralConcatenation) {
126124 " 'bbbbb'" );
127125 verifyFormat (" field_a: \" aaaaa\"\n "
128126 " \" bbbbb\" " );
129- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto);
127+
128+ auto Style = getDefaultStyle ();
130129 Style.AlwaysBreakBeforeMultilineStrings = true ;
131130 verifyFormat (" field_a:\n "
132131 " 'aaaaa'\n "
@@ -359,46 +358,40 @@ TEST_F(FormatTestTextProto, KeepsCommentsIndentedInList) {
359358}
360359
361360TEST_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);
385384
386385 // 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);
402395}
403396
404397TEST_F (FormatTestTextProto, FormatsExtensions) {
@@ -519,8 +512,8 @@ TEST_F(FormatTestTextProto, FormatsRepeatedListInitializers) {
519512 " ]\n "
520513 " }\n "
521514 " key: value" );
522- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto);
523- Style. ColumnLimit = 60 ; // To make writing tests easier.
515+
516+ auto Style = getDefaultStyle ();
524517 Style.Cpp11BracedListStyle = true ;
525518 verifyFormat (" keys: [1]" , Style);
526519}
@@ -544,7 +537,6 @@ TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) {
544537}
545538
546539TEST_F (FormatTestTextProto, PutsMultipleEntriesInExtensionsOnNewlines) {
547- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto);
548540 verifyFormat (" pppppppppp: {\n "
549541 " ssssss: \" http://example.com/blahblahblah\"\n "
550542 " ppppppp: \" sssss/MMMMMMMMMMMM\"\n "
@@ -556,12 +548,10 @@ TEST_F(FormatTestTextProto, PutsMultipleEntriesInExtensionsOnNewlines) {
556548 " key: value\n "
557549 " }\n "
558550 " }" ,
559- Style );
551+ getGoogleStyle (FormatStyle::LK_TextProto) );
560552}
561553
562554TEST_F (FormatTestTextProto, BreaksAfterBraceFollowedByClosingBraceOnNextLine) {
563- FormatStyle Style = getGoogleStyle (FormatStyle::LK_TextProto);
564- Style.ColumnLimit = 60 ;
565555 verifyFormat (" keys: [\n "
566556 " data: { item: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }\n "
567557 " ]" );
@@ -571,10 +561,6 @@ TEST_F(FormatTestTextProto, BreaksAfterBraceFollowedByClosingBraceOnNextLine) {
571561}
572562
573563TEST_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.
578564 verifyFormat (" key: valueeeeeeee\n "
579565 " keys: {\n "
580566 " item: 'aaaaaaaaaaaaaaaa'\n "
0 commit comments