@@ -28430,6 +28430,7 @@ TEST_F(FormatTest, ShortNamespacesOption) {
2843028430TEST_F(FormatTest, WrapNamespaceBodyWithEmptyLinesNever) {
2843128431 auto Style = getLLVMStyle();
2843228432 Style.FixNamespaceComments = false;
28433+ Style.MaxEmptyLinesToKeep = 2;
2843328434 Style.WrapNamespaceBodyWithEmptyLines = FormatStyle::WNBWELS_Never;
2843428435
2843528436 // Empty namespace.
@@ -28439,6 +28440,13 @@ TEST_F(FormatTest, WrapNamespaceBodyWithEmptyLinesNever) {
2843928440 verifyFormat("namespace N {\n"
2844028441 "int f1(int a) { return 2 * a; }\n"
2844128442 "}",
28443+ "namespace N {\n"
28444+ "\n"
28445+ "\n"
28446+ "int f1(int a) { return 2 * a; }\n"
28447+ "\n"
28448+ "\n"
28449+ "}",
2844228450 Style);
2844328451
2844428452 // Nested namespace.
@@ -28447,46 +28455,38 @@ TEST_F(FormatTest, WrapNamespaceBodyWithEmptyLinesNever) {
2844728455 "int a = 1;\n"
2844828456 "}\n"
2844928457 "}",
28450- Style);
28451-
28452- Style.CompactNamespaces = true;
28453-
28454- verifyFormat("namespace N1 { namespace N2 {\n"
28455- "int a = 1;\n"
28456- "}}",
28457- Style);
28458-
28459- // Removing empty lines.
28460- verifyFormat("namespace N {\n"
28461- "int a = 1;\n"
28462- "}",
28463- "namespace N {\n"
28458+ "namespace N1 {\n"
2846428459 "\n"
2846528460 "\n"
28461+ "namespace N2 {\n"
28462+ "\n"
2846628463 "int a = 1;\n"
2846728464 "\n"
28465+ "}\n"
28466+ "\n"
2846828467 "\n"
2846928468 "}",
2847028469 Style);
2847128470
28472- Style.MaxEmptyLinesToKeep = 0 ;
28471+ Style.CompactNamespaces = true ;
2847328472
28474- verifyFormat("namespace N {\n"
28473+ verifyFormat("namespace N1 { namespace N2 {\n"
2847528474 "int a = 1;\n"
28476- "}",
28477- "namespace N {\n"
28475+ "}} ",
28476+ "namespace N1 { namespace N2 {\n"
2847828477 "\n"
2847928478 "\n"
2848028479 "int a = 1;\n"
2848128480 "\n"
2848228481 "\n"
28483- "}",
28482+ "}} ",
2848428483 Style);
2848528484}
2848628485
2848728486TEST_F(FormatTest, WrapNamespaceBodyWithEmptyLinesAlways) {
2848828487 auto Style = getLLVMStyle();
2848928488 Style.FixNamespaceComments = false;
28489+ Style.MaxEmptyLinesToKeep = 2;
2849028490 Style.WrapNamespaceBodyWithEmptyLines = FormatStyle::WNBWELS_Always;
2849128491
2849228492 // Empty namespace.
@@ -28498,6 +28498,9 @@ TEST_F(FormatTest, WrapNamespaceBodyWithEmptyLinesAlways) {
2849828498 "int f1(int a) { return 2 * a; }\n"
2849928499 "\n"
2850028500 "}",
28501+ "namespace N {\n"
28502+ "int f1(int a) { return 2 * a; }\n"
28503+ "}",
2850128504 Style);
2850228505
2850328506 // Nested namespace.
@@ -28508,53 +28511,50 @@ TEST_F(FormatTest, WrapNamespaceBodyWithEmptyLinesAlways) {
2850828511 "\n"
2850928512 "}\n"
2851028513 "}",
28514+ "namespace N1 {\n"
28515+ "namespace N2 {\n"
28516+ "int a = 1;\n"
28517+ "}\n"
28518+ "}",
28519+ Style);
28520+
28521+ verifyFormat("namespace N1 {\n"
28522+ "\n"
28523+ "namespace N2 {\n"
28524+ "\n"
28525+ "\n"
28526+ "int a = 1;\n"
28527+ "\n"
28528+ "\n"
28529+ "}\n"
28530+ "\n"
28531+ "}",
28532+ "namespace N1 {\n"
28533+ "\n"
28534+ "namespace N2 {\n"
28535+ "\n"
28536+ "\n"
28537+ "\n"
28538+ "int a = 1;\n"
28539+ "\n"
28540+ "\n"
28541+ "\n"
28542+ "}\n"
28543+ "\n"
28544+ "}",
2851128545 Style);
2851228546
2851328547 Style.CompactNamespaces = true;
2851428548
28515- // Nested namespace.
2851628549 verifyFormat("namespace N1 { namespace N2 {\n"
2851728550 "\n"
2851828551 "int a = 1;\n"
2851928552 "\n"
2852028553 "}}",
28554+ "namespace N1 { namespace N2 {\n"
28555+ "int a = 1;\n"
28556+ "}}",
2852128557 Style);
28522-
28523- Style.MaxEmptyLinesToKeep = 2;
28524-
28525- // Nested namespace.
28526- verifyNoChange("namespace N1 { namespace N2 {\n"
28527- "\n"
28528- "\n"
28529- "int a = 1;\n"
28530- "\n"
28531- "\n"
28532- "}}",
28533- Style);
28534-
28535- Style.CompactNamespaces = false;
28536-
28537- // Single namespace.
28538- verifyNoChange("namespace N {\n"
28539- "\n"
28540- "\n"
28541- "int a = 1;\n"
28542- "\n"
28543- "\n"
28544- "}",
28545- Style);
28546-
28547- // Nested namespace.
28548- verifyNoChange("namespace N1 {\n"
28549- "namespace N2 {\n"
28550- "\n"
28551- "\n"
28552- "int a = 1;\n"
28553- "\n"
28554- "\n"
28555- "}\n"
28556- "}",
28557- Style);
2855828558}
2855928559
2856028560} // namespace
0 commit comments