@@ -11229,19 +11229,6 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
11229
11229
// Begin with tests covering the case where there is no constraint on the
11230
11230
// column limit.
11231
11231
Style.ColumnLimit = 0;
11232
- // When BreakBeforeTemplateCloser is turned off, the line break that it adds
11233
- // shall be removed:
11234
- verifyFormat("template <\n"
11235
- " typename Foo,\n"
11236
- " typename Bar>\n"
11237
- "void foo() {}",
11238
- "template <\n"
11239
- " typename Foo,\n"
11240
- " typename Bar\n"
11241
- ">\n"
11242
- "void foo() {}",
11243
- Style);
11244
-
11245
11232
Style.BreakBeforeTemplateCloser = true;
11246
11233
// BreakBeforeTemplateCloser should NOT force template declarations onto
11247
11234
// multiple lines.
@@ -11258,16 +11245,6 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
11258
11245
">\n"
11259
11246
"void foo() {}",
11260
11247
Style);
11261
- verifyNoChange("template <\n"
11262
- " typename Foo,\n"
11263
- " typename Bar\n"
11264
- ">\n"
11265
- "void foo() {}",
11266
- Style);
11267
- verifyNoChange("template <typename Foo,\n"
11268
- " typename Bar>\n"
11269
- "void foo() {}",
11270
- Style);
11271
11248
// It should add a line break before > if not already present:
11272
11249
verifyFormat("template <\n"
11273
11250
" typename Foo\n"
@@ -11311,12 +11288,12 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
11311
11288
" T0,\n"
11312
11289
" T1\n"
11313
11290
" >\n"
11314
- ">;\n ",
11291
+ ">;",
11315
11292
"using type = std::remove_cv_t<\n"
11316
11293
" add_common_cv_reference<\n"
11317
11294
" std::common_type_t<std::decay_t<T0>, std::decay_t<T1>>,\n"
11318
11295
" T0,\n"
11319
- " T1>>;\n ",
11296
+ " T1>>;",
11320
11297
Style);
11321
11298
11322
11299
// Test lambda goes to next line:
@@ -11361,12 +11338,6 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
11361
11338
"}",
11362
11339
Style);
11363
11340
11364
- // Note that this is the same line (no \n):
11365
- verifyFormat("void foo() {\n"
11366
- " auto lambda = []<typename T>(T t) {};\n"
11367
- "}",
11368
- Style);
11369
-
11370
11341
// Test template usage goes to next line too:
11371
11342
verifyFormat("void foo() {\n"
11372
11343
" myFunc<\n"
@@ -11381,29 +11352,11 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
11381
11352
11382
11353
// Now test that it handles the cases when the column limit forces wrapping.
11383
11354
Style.ColumnLimit = 40;
11384
- // When the column limit allows it, the template should be combined back into
11385
- // one line:
11386
- verifyFormat("template <typename Foo, typename Bar>\n"
11387
- "void foo() {}",
11388
- "template <\n"
11389
- " typename Foo,\n"
11390
- " typename Bar\n"
11391
- ">\n"
11392
- "void foo() {}",
11393
- Style);
11394
- // But not when the name is looong. Note that these names are exactly 1
11355
+ // Breaks when the name is looong. Note that these names are exactly 1
11395
11356
// character too long for the ColumnLimit.
11396
11357
verifyFormat("template <\n"
11397
11358
" typename Foo,\n"
11398
- " typename Barrrrrrrrrrrrrrrrrrrr\n"
11399
- ">\n"
11400
- "void foo() {}",
11401
- Style);
11402
- // Note that this "Foo" is 1 character shorter than the previous "Bar" because
11403
- // of the comma.
11404
- verifyFormat("template <\n"
11405
- " typename Foooooooooooooooooooo,\n"
11406
- " typename Bar\n"
11359
+ " typename Barrrrrrrrrrrrrrrrrrr\n"
11407
11360
">\n"
11408
11361
"void foo() {}",
11409
11362
Style);
@@ -11416,42 +11369,29 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
11416
11369
" typename Bar>\n"
11417
11370
"void foo() {}",
11418
11371
Style);
11419
- // Same check for only one template parameter.
11420
- // Note how the first line is exactly 40 chars:
11421
- verifyFormat("template <typename Barrrrrrrrrrrrrrrrrr>\n"
11372
+ // Additionally, long names should be split in one step:
11373
+ verifyFormat("template <\n"
11374
+ " typename Foo,\n"
11375
+ " typename Barrrrrrrrrrrrrrrrrrr\n"
11376
+ ">\n"
11377
+ "void foo() {}",
11378
+ "template <typename Foo, typename Barrrrrrrrrrrrrrrrrrr>\n"
11422
11379
"void foo() {}",
11423
11380
Style);
11424
- // And when one more "r" is added, it breaks properly:
11425
11381
verifyFormat("template <\n"
11426
- " typename Barrrrrrrrrrrrrrrrrrr\n"
11382
+ " typename Foooooooooooooooooooo,\n"
11383
+ " typename Bar\n"
11427
11384
">\n"
11428
11385
"void foo() {}",
11386
+ "template <typename Foooooooooooooooooooo, typename Bar>\n"
11387
+ "void foo() {}",
11429
11388
Style);
11430
- // Additionally, long names should be split in one step:
11431
- verifyFormat(
11432
- "template <\n"
11433
- " typename Foo,\n"
11434
- " typename Barrrrrrrrrrrrrrrrrrrrrrrrrr\n"
11435
- ">\n"
11436
- "void foo() {}",
11437
- "template <typename Foo, typename Barrrrrrrrrrrrrrrrrrrrrrrrrr>\n"
11438
- "void foo() {}",
11439
- Style);
11440
- verifyFormat(
11441
- "template <\n"
11442
- " typename Fooooooooooooooooooooooooooo,\n"
11443
- " typename Bar\n"
11444
- ">\n"
11445
- "void foo() {}",
11446
- "template <typename Fooooooooooooooooooooooooooo, typename Bar>\n"
11447
- "void foo() {}",
11448
- Style);
11449
11389
// Even when there is only one long name:
11450
11390
verifyFormat("template <\n"
11451
- " typename Fooooooooooooooooooooooooooo \n"
11391
+ " typename Foooooooooooooooooooo \n"
11452
11392
">\n"
11453
11393
"void foo() {}",
11454
- "template <typename Fooooooooooooooooooooooooooo >\n"
11394
+ "template <typename Foooooooooooooooooooo >\n"
11455
11395
"void foo() {}",
11456
11396
Style);
11457
11397
// Test lambda goes to next line if the type is looong:
@@ -11520,20 +11460,13 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
11520
11460
"}",
11521
11461
Style);
11522
11462
11523
- // Test template usage goes to next line only if the type is looong:
11524
- verifyFormat("void foo() { myFunc<T>(); }", Style);
11463
+ // Test template usage goes to next line if the type is looong:
11525
11464
verifyFormat("void foo() {\n"
11526
11465
" myFunc<\n"
11527
- " Loooooooooooooooooooooooooooooooooooooooong \n"
11466
+ " Looooooooooooooooooooooooong \n"
11528
11467
" >();\n"
11529
11468
"}",
11530
11469
Style);
11531
- // But if the type is short, we don't need block indent style:
11532
- verifyFormat("void foo() {\n"
11533
- " myFunc<Foo, Foo, Foo, Foo, Foo, Foo,\n"
11534
- " Foo, Foo>();\n"
11535
- "}",
11536
- Style);
11537
11470
// Even a single type in the middle is enough to force it to block indent
11538
11471
// style:
11539
11472
verifyFormat("void foo() {\n"
0 commit comments