diff options
Diffstat (limited to 'unittests/Format/FormatTestComments.cpp')
-rw-r--r-- | unittests/Format/FormatTestComments.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/unittests/Format/FormatTestComments.cpp b/unittests/Format/FormatTestComments.cpp index a44a6845587d..fdb5a08e7a21 100644 --- a/unittests/Format/FormatTestComments.cpp +++ b/unittests/Format/FormatTestComments.cpp @@ -1052,6 +1052,30 @@ TEST_F(FormatTestComments, KeepsTrailingPPCommentsAndSectionCommentsSeparate) { "}", getLLVMStyleWithColumns(80)); } +TEST_F(FormatTestComments, AlignsPPElseEndifComments) { + verifyFormat("#if A\n" + "#else // A\n" + "int iiii;\n" + "#endif // B", + getLLVMStyleWithColumns(20)); + verifyFormat("#if A\n" + "#else // A\n" + "int iiii; // CC\n" + "#endif // B", + getLLVMStyleWithColumns(20)); + EXPECT_EQ("#if A\n" + "#else // A1\n" + " // A2\n" + "int ii;\n" + "#endif // B", + format("#if A\n" + "#else // A1\n" + " // A2\n" + "int ii;\n" + "#endif // B", + getLLVMStyleWithColumns(20))); +} + TEST_F(FormatTestComments, CommentsInStaticInitializers) { EXPECT_EQ( "static SomeType type = {aaaaaaaaaaaaaaaaaaaa, /* comment */\n" @@ -2170,6 +2194,15 @@ TEST_F(FormatTestComments, AlignTrailingComments) { "// long", getLLVMStyleWithColumns(15))); + // Don't align newly broken trailing comments if that would put them over the + // column limit. + EXPECT_EQ("int i, j; // line 1\n" + "int k; // line longg\n" + " // long", + format("int i, j; // line 1\n" + "int k; // line longg long", + getLLVMStyleWithColumns(20))); + // Align comment line sections aligned with the next token with the next // token. EXPECT_EQ("class A {\n" |