Skip to content

Commit 6c3bc91

Browse files
committed
[clang-format][NFC] Remove more extraneous newlines in unit tests
Also removed a duplicate test case.
1 parent ec7c1a4 commit 6c3bc91

8 files changed

+77
-82
lines changed

clang/unittests/Format/FormatTestObjC.cpp

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -62,35 +62,33 @@ TEST(FormatTestObjCStyle, DetectsObjCInHeaders) {
6262
ASSERT_TRUE((bool)Style);
6363
EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
6464

65-
Style = getStyle("{}", "a.h", "none", "@interface Foo\n@end\n");
65+
Style = getStyle("{}", "a.h", "none", "@interface Foo\n@end");
6666
ASSERT_TRUE((bool)Style);
6767
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
6868

6969
Style = getStyle("{}", "a.h", "none",
70-
"const int interface = 1;\nconst int end = 2;\n");
70+
"const int interface = 1;\nconst int end = 2;");
7171
ASSERT_TRUE((bool)Style);
7272
EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
7373

74-
Style = getStyle("{}", "a.h", "none", "@protocol Foo\n@end\n");
74+
Style = getStyle("{}", "a.h", "none", "@protocol Foo\n@end");
7575
ASSERT_TRUE((bool)Style);
7676
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
7777

7878
Style = getStyle("{}", "a.h", "none",
79-
"const int protocol = 1;\nconst int end = 2;\n");
79+
"const int protocol = 1;\nconst int end = 2;");
8080
ASSERT_TRUE((bool)Style);
8181
EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
8282

83-
Style = getStyle("{}", "a.h", "none", "typedef NS_ENUM(int, Foo) {};\n");
83+
Style = getStyle("{}", "a.h", "none", "typedef NS_ENUM(int, Foo) {};");
8484
ASSERT_TRUE((bool)Style);
8585
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
8686

87-
Style =
88-
getStyle("{}", "a.h", "none", "typedef NS_CLOSED_ENUM(int, Foo) {};\n");
87+
Style = getStyle("{}", "a.h", "none", "typedef NS_CLOSED_ENUM(int, Foo) {};");
8988
ASSERT_TRUE((bool)Style);
9089
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
9190

92-
Style =
93-
getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};\n");
91+
Style = getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};");
9492
ASSERT_TRUE((bool)Style);
9593
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
9694

@@ -118,45 +116,43 @@ FOUNDATION_EXPORT void DoStuff(void);
118116
ASSERT_TRUE((bool)Style);
119117
EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
120118

121-
Style =
122-
getStyle("{}", "a.h", "none", "inline void Foo() { Log(@\"Foo\"); }\n");
119+
Style = getStyle("{}", "a.h", "none", "inline void Foo() { Log(@\"Foo\"); }");
123120
ASSERT_TRUE((bool)Style);
124121
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
125122

126-
Style =
127-
getStyle("{}", "a.h", "none", "inline void Foo() { Log(\"Foo\"); }\n");
123+
Style = getStyle("{}", "a.h", "none", "inline void Foo() { Log(\"Foo\"); }");
128124
ASSERT_TRUE((bool)Style);
129125
EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
130126

131127
Style =
132-
getStyle("{}", "a.h", "none", "inline void Foo() { id = @[1, 2, 3]; }\n");
128+
getStyle("{}", "a.h", "none", "inline void Foo() { id = @[1, 2, 3]; }");
133129
ASSERT_TRUE((bool)Style);
134130
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
135131

136132
Style = getStyle("{}", "a.h", "none",
137-
"inline void Foo() { id foo = @{1: 2, 3: 4, 5: 6}; }\n");
133+
"inline void Foo() { id foo = @{1: 2, 3: 4, 5: 6}; }");
138134
ASSERT_TRUE((bool)Style);
139135
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
140136

141137
Style = getStyle("{}", "a.h", "none",
142-
"inline void Foo() { int foo[] = {1, 2, 3}; }\n");
138+
"inline void Foo() { int foo[] = {1, 2, 3}; }");
143139
ASSERT_TRUE((bool)Style);
144140
EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
145141

146142
// ObjC characteristic types.
147-
Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
143+
Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;");
148144
ASSERT_TRUE((bool)Style);
149145
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
150146

151-
Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
147+
Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();");
152148
ASSERT_TRUE((bool)Style);
153149
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
154150

155-
Style = getStyle("{}", "a.h", "none", "NSObject *Foo();\n");
151+
Style = getStyle("{}", "a.h", "none", "NSObject *Foo();");
156152
ASSERT_TRUE((bool)Style);
157153
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
158154

159-
Style = getStyle("{}", "a.h", "none", "NSSet *Foo();\n");
155+
Style = getStyle("{}", "a.h", "none", "NSSet *Foo();");
160156
ASSERT_TRUE((bool)Style);
161157
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
162158
}
@@ -187,7 +183,7 @@ TEST_F(FormatTestObjC, FormatObjCTryCatch) {
187183
" @try {\n"
188184
" } @finally {\n"
189185
" }\n"
190-
"});\n");
186+
"});");
191187
}
192188

193189
TEST_F(FormatTestObjC, FormatObjCAutoreleasepool) {
@@ -196,7 +192,7 @@ TEST_F(FormatTestObjC, FormatObjCAutoreleasepool) {
196192
"}\n"
197193
"@autoreleasepool {\n"
198194
" f();\n"
199-
"}\n");
195+
"}");
200196
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
201197
Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
202198
verifyFormat("@autoreleasepool\n"
@@ -206,18 +202,18 @@ TEST_F(FormatTestObjC, FormatObjCAutoreleasepool) {
206202
"@autoreleasepool\n"
207203
"{\n"
208204
" f();\n"
209-
"}\n");
205+
"}");
210206
}
211207

212208
TEST_F(FormatTestObjC, FormatObjCGenerics) {
213209
Style.ColumnLimit = 40;
214210
verifyFormat("int aaaaaaaaaaaaaaaa(\n"
215211
" NSArray<aaaaaaaaaaaaaaaaaa *>\n"
216-
" aaaaaaaaaaaaaaaaa);\n");
212+
" aaaaaaaaaaaaaaaaa);");
217213
verifyFormat("int aaaaaaaaaaaaaaaa(\n"
218214
" NSArray<aaaaaaaaaaaaaaaaaaa<\n"
219215
" aaaaaaaaaaaaaaaa *> *>\n"
220-
" aaaaaaaaaaaaaaaaa);\n");
216+
" aaaaaaaaaaaaaaaaa);");
221217
}
222218

223219
TEST_F(FormatTestObjC, FormatObjCSynchronized) {
@@ -226,7 +222,7 @@ TEST_F(FormatTestObjC, FormatObjCSynchronized) {
226222
"}\n"
227223
"@synchronized(self) {\n"
228224
" f();\n"
229-
"}\n");
225+
"}");
230226
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
231227
Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
232228
verifyFormat("@synchronized(self)\n"
@@ -236,7 +232,7 @@ TEST_F(FormatTestObjC, FormatObjCSynchronized) {
236232
"@synchronized(self)\n"
237233
"{\n"
238234
" f();\n"
239-
"}\n");
235+
"}");
240236
}
241237

242238
TEST_F(FormatTestObjC, FormatObjCInterface) {
@@ -409,7 +405,7 @@ TEST_F(FormatTestObjC, FormatObjCInterface) {
409405
Style.ColumnLimit = 40;
410406
// BinPackParameters should be true by default.
411407
verifyFormat("void eeeeeeee(int eeeee, int eeeee,\n"
412-
" int eeeee, int eeeee);\n");
408+
" int eeeee, int eeeee);");
413409
// ObjCBinPackProtocolList should be BPS_Never by default.
414410
verifyFormat("@interface fffffffffffff () <\n"
415411
" fffffffffffff,\n"
@@ -511,7 +507,7 @@ TEST_F(FormatTestObjC, FormatObjCProtocol) {
511507
"@end");
512508

513509
verifyFormat("@protocol Foo;\n"
514-
"@protocol Bar;\n");
510+
"@protocol Bar;");
515511

516512
verifyFormat("@protocol Foo\n"
517513
"@end\n"
@@ -530,7 +526,7 @@ TEST_F(FormatTestObjC, FormatObjCProtocol) {
530526
"- (void)required;\n"
531527
"@optional\n"
532528
"@property(assign) int madProp;\n"
533-
"@end\n");
529+
"@end");
534530

535531
verifyFormat("@property(nonatomic, assign, readonly)\n"
536532
" int *looooooooooooooooooooooooooooongNumber;\n"
@@ -562,7 +558,7 @@ TEST_F(FormatTestObjC, FormatObjCMethodDeclarations) {
562558
" evenLongerKeyword:(float)theInterval\n"
563559
" error:(NSError **)theError {\n"
564560
"}");
565-
verifyFormat("+ (instancetype)new;\n");
561+
verifyFormat("+ (instancetype)new;");
566562
Style.ColumnLimit = 60;
567563
verifyFormat("- (instancetype)initXxxxxx:(id<x>)x\n"
568564
" y:(id<yyyyyyyyyyyyyyyyyyyy>)y\n"
@@ -573,18 +569,18 @@ TEST_F(FormatTestObjC, FormatObjCMethodDeclarations) {
573569
Style.ColumnLimit = 40;
574570
// Make sure selectors with 0, 1, or more arguments are indented when wrapped.
575571
verifyFormat("- (aaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
576-
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa;\n");
572+
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa;");
577573
verifyFormat("- (aaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
578-
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a;\n");
574+
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a;");
579575
verifyFormat("- (aaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
580576
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a\n"
581-
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a;\n");
577+
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a;");
582578
verifyFormat("- (aaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
583579
" aaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a\n"
584-
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a;\n");
580+
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a;");
585581
verifyFormat("- (aaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
586582
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a\n"
587-
" aaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a;\n");
583+
" aaaaaaaaaaaaaaaaaaaaaaaaaaa:(int)a;");
588584

589585
// Continuation indent width should win over aligning colons if the function
590586
// name is long.
@@ -618,7 +614,7 @@ TEST_F(FormatTestObjC, FormatObjCMethodDeclarations) {
618614
"- (void)foo:(id)bar\n"
619615
"{\n"
620616
"}\n"
621-
"@end\n");
617+
"@end");
622618
}
623619

624620
TEST_F(FormatTestObjC, FormatObjCMethodExpr) {
@@ -1109,30 +1105,30 @@ TEST_F(FormatTestObjC, ObjCForIn) {
11091105
TEST_F(FormatTestObjC, ObjCCxxKeywords) {
11101106
verifyFormat("+ (instancetype)new {\n"
11111107
" return nil;\n"
1112-
"}\n");
1108+
"}");
11131109
verifyFormat("+ (instancetype)myNew {\n"
11141110
" return [self new];\n"
1115-
"}\n");
1116-
verifyFormat("SEL NewSelector(void) { return @selector(new); }\n");
1117-
verifyFormat("SEL MacroSelector(void) { return MACRO(new); }\n");
1111+
"}");
1112+
verifyFormat("SEL NewSelector(void) { return @selector(new); }");
1113+
verifyFormat("SEL MacroSelector(void) { return MACRO(new); }");
11181114
verifyFormat("+ (instancetype)delete {\n"
11191115
" return nil;\n"
1120-
"}\n");
1116+
"}");
11211117
verifyFormat("+ (instancetype)myDelete {\n"
11221118
" return [self delete];\n"
1123-
"}\n");
1124-
verifyFormat("SEL DeleteSelector(void) { return @selector(delete); }\n");
1125-
verifyFormat("SEL MacroSelector(void) { return MACRO(delete); }\n");
1126-
verifyFormat("MACRO(new:)\n");
1127-
verifyFormat("MACRO(delete:)\n");
1128-
verifyFormat("foo = @{MACRO(new:) : MACRO(delete:)}\n");
1119+
"}");
1120+
verifyFormat("SEL DeleteSelector(void) { return @selector(delete); }");
1121+
verifyFormat("SEL MacroSelector(void) { return MACRO(delete); }");
1122+
verifyFormat("MACRO(new:)");
1123+
verifyFormat("MACRO(delete:)");
1124+
verifyFormat("foo = @{MACRO(new:) : MACRO(delete:)}");
11291125
verifyFormat("@implementation Foo\n"
11301126
"// Testing\n"
11311127
"- (Class)class {\n"
11321128
"}\n"
11331129
"- (void)foo {\n"
11341130
"}\n"
1135-
"@end\n");
1131+
"@end");
11361132
verifyFormat("@implementation Foo\n"
11371133
"- (Class)class {\n"
11381134
"}\n"
@@ -1162,7 +1158,7 @@ TEST_F(FormatTestObjC, ObjCCxxKeywords) {
11621158
"// Testing\n"
11631159
"- (Class)class;\n"
11641160
"- (void)foo;\n"
1165-
"@end\n");
1161+
"@end");
11661162
verifyFormat("@interface Foo\n"
11671163
"- (Class)class;\n"
11681164
"- (void)foo;\n"
@@ -1354,7 +1350,7 @@ TEST_F(FormatTestObjC, ObjCArrayLiterals) {
13541350
// (that raises -Wobjc-string-concatenation).
13551351
verifyFormat("NSArray *foo = @[\n"
13561352
" @\"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n"
1357-
"];\n");
1353+
"];");
13581354
}
13591355

13601356
TEST_F(FormatTestObjC, BreaksCallStatementWhereSemiJustOverTheLimit) {

clang/unittests/Format/FormatTestProto.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ TEST_F(FormatTestProto, DoesntWrapFileOptions) {
201201
}
202202

203203
TEST_F(FormatTestProto, TrailingCommentAfterFileOption) {
204-
verifyFormat("option java_package = \"foo.pkg\"; // comment\n");
204+
verifyFormat("option java_package = \"foo.pkg\"; // comment");
205205
}
206206

207207
TEST_F(FormatTestProto, FormatsOptions) {
@@ -411,7 +411,7 @@ TEST_F(FormatTestProto, DoesntWrapPackageStatements) {
411411
}
412412

413413
TEST_F(FormatTestProto, TrailingCommentAfterPackage) {
414-
verifyFormat("package foo.pkg; // comment\n");
414+
verifyFormat("package foo.pkg; // comment");
415415
}
416416

417417
TEST_F(FormatTestProto, FormatsService) {

clang/unittests/Format/FormatTestSelective.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ TEST_F(FormatTestSelective, ContinueReindenting) {
185185
"int c;\n"
186186
"int d;\n"
187187
"int e;\n"
188-
" int f;\n",
188+
" int f;",
189189
format("int i;\n"
190190
" int b;\n"
191191
" int c;\n"
192192
" int d;\n"
193193
"int e;\n"
194-
" int f;\n",
194+
" int f;",
195195
11, 0));
196196
}
197197

@@ -201,13 +201,13 @@ TEST_F(FormatTestSelective, ReindentClosingBrace) {
201201
" int a;\n"
202202
" int b;\n"
203203
"}\n"
204-
" int c;\n",
204+
" int c;",
205205
format("int i;\n"
206206
" int f(){\n"
207207
"int a;\n"
208208
"int b;\n"
209209
" }\n"
210-
" int c;\n",
210+
" int c;",
211211
11, 0));
212212
EXPECT_EQ("void f() {\n"
213213
" if (foo) {\n"
@@ -216,30 +216,30 @@ TEST_F(FormatTestSelective, ReindentClosingBrace) {
216216
" c();\n"
217217
" }\n"
218218
"int d;\n"
219-
"}\n",
219+
"}",
220220
format("void f() {\n"
221221
" if (foo) {\n"
222222
"b();\n"
223223
"}else{\n"
224224
"c();\n"
225225
"}\n"
226226
"int d;\n"
227-
"}\n",
227+
"}",
228228
13, 0));
229229
EXPECT_EQ("int i = []() {\n"
230230
" class C {\n"
231231
" int a;\n"
232232
" int b;\n"
233233
" };\n"
234234
" int c;\n"
235-
"};\n",
235+
"};",
236236
format("int i = []() {\n"
237237
" class C{\n"
238238
"int a;\n"
239239
"int b;\n"
240240
"};\n"
241241
"int c;\n"
242-
" };\n",
242+
" };",
243243
17, 0));
244244
}
245245

clang/unittests/Format/FormatTestTableGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ TEST_F(FormatTestTableGen, FormatStringBreak) {
4848
" HelpText<\n"
4949
" \"This is a very, very, very, very, \"\n"
5050
" \"very, very, very, very, very, very, \"\n"
51-
" \"very long help string\">;\n");
51+
" \"very long help string\">;");
5252
}
5353

5454
TEST_F(FormatTestTableGen, NoSpacesInSquareBracketLists) {
55-
verifyFormat("def flag : Flag<[\"-\", \"--\"], \"foo\">;\n");
55+
verifyFormat("def flag : Flag<[\"-\", \"--\"], \"foo\">;");
5656
}
5757

5858
} // namespace format

0 commit comments

Comments
 (0)