diff options
author | Daniel Jasper <djasper@google.com> | 2013-01-18 08:44:07 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-01-18 08:44:07 +0000 |
commit | dcc2a6269ba86285b20ee76487807b9cd20cefbe (patch) | |
tree | 2932ce6362e90a1855f0de4eca76bb47e363a40b /unittests/Format/FormatTest.cpp | |
parent | 94fb72932c806c549f5c51f4bfa99fa7b481324a (diff) |
Let the formatter align trailing line comments where possible.
Before:
int a; // comment
int bbbbb; // comment
After:
int a; // comment
int bbbbb; // comment
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172798 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 2a2bb3fe6d..7013eb1417 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -352,8 +352,8 @@ TEST_F(FormatTest, UnderstandsSingleLineComments) { verifyFormat("void f() {\n" " // Doesn't do anything\n" "}"); - verifyFormat("void f(int i, // some comment (probably for i)\n" - " int j, // some comment (probably for j)\n" + verifyFormat("void f(int i, // some comment (probably for i)\n" + " int j, // some comment (probably for j)\n" " int k); // some comment (probably for k)"); verifyFormat("void f(int i,\n" " // some comment (probably for j)\n" @@ -361,8 +361,32 @@ TEST_F(FormatTest, UnderstandsSingleLineComments) { " // some comment (probably for k)\n" " int k);"); - verifyFormat("int i // This is a fancy variable\n" - " = 5;"); + verifyFormat("int i // This is a fancy variable\n" + " = 5; // with nicely aligned comment."); + + verifyFormat("// Leading comment.\n" + "int a; // Trailing comment."); + verifyFormat("int a; // Trailing comment\n" + " // on 2\n" + " // or 3 lines.\n" + "int b;"); + verifyFormat("int a; // Trailing comment\n" + "\n" + "// Leading comment.\n" + "int b;"); + verifyFormat("int a; // Comment.\n" + " // More details.\n" + "int bbbb; // Another comment."); + verifyFormat( + "int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; // comment\n" + "int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; // comment\n" + "int cccccccccccccccccccccccccccccc; // comment\n" + "int ddd; // looooooooooooooooooooooooong comment\n" + "int aaaaaaaaaaaaaaaaaaaaaaa; // comment\n" + "int bbbbbbbbbbbbbbbbbbbbb; // comment\n" + "int ccccccccccccccccccc; // comment"); + + verifyFormat("enum E {\n" " // comment\n" @@ -835,7 +859,7 @@ TEST_F(FormatTest, ConstructorInitializers) { " aaaaaaaaaaaaaaaaaaaaat(aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}"); verifyGoogleFormat("MyClass::MyClass(int var)\n" - " : some_var_(var), // 4 space indent\n" + " : some_var_(var), // 4 space indent\n" " some_other_var_(var + 1) { // lined up\n" "}"); |