diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:22 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:22 +0000 |
commit | 1b08b196ac845675036ac78f3ac927d0a37f707c (patch) | |
tree | 1fbd923674e903831dc097fdb4fdfd64dd6e47b1 /unittests/Format/FormatTestComments.cpp | |
parent | 551c698530debaae81139c7c76a29fb762793362 (diff) |
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" |