diff options
author | Daniel Jasper <djasper@google.com> | 2013-07-01 11:22:57 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-07-01 11:22:57 +0000 |
commit | 251b3c9e7efe38e9f86d1a17279e03f57e963376 (patch) | |
tree | b34730222d887b9c9bb59eb7e31f21e8e8ca18f7 /clang/unittests | |
parent | 7a1ad5e6056e5c033c4f9f041a5166c6581998cf (diff) | |
download | bcm5719-llvm-251b3c9e7efe38e9f86d1a17279e03f57e963376.tar.gz bcm5719-llvm-251b3c9e7efe38e9f86d1a17279e03f57e963376.zip |
Don't align "} // namespace" comments.
This is not all bad, but people are often surprised by it.
Before:
namespace {
int SomeVariable = 0; // comment
} // namespace
After:
namespace {
int SomeVariable = 0; // comment
} // namespace
llvm-svn: 185327
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 5bdc1b949d9..5227554d65c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -648,14 +648,17 @@ TEST_F(FormatTest, UnderstandsSingleLineComments) { format("void f() { // This does something ..\n" " }\n" "int a; // This is unrelated")); - EXPECT_EQ("void f() { // This does something ..\n" - "} // awesome..\n" + EXPECT_EQ("class C {\n" + " void f() { // This does something ..\n" + " } // awesome..\n" "\n" - "int a; // This is unrelated", - format("void f() { // This does something ..\n" + " int a; // This is unrelated\n" + "};", + format("class C{void f() { // This does something ..\n" " } // awesome..\n" " \n" - "int a; // This is unrelated")); + "int a; // This is unrelated\n" + "};")); EXPECT_EQ("int i; // single line trailing comment", format("int i;\\\n// single line trailing comment")); @@ -1479,6 +1482,22 @@ TEST_F(FormatTest, FormatsNamespaces) { verifyFormat("namespace {\n" "class A {};\n" "};"); + + verifyFormat("namespace {\n" + "int SomeVariable = 0; // comment\n" + "} // namespace"); + EXPECT_EQ("#ifndef HEADER_GUARD\n" + "#define HEADER_GUARD\n" + "namespace my_namespace {\n" + "int i;\n" + "} // my_namespace\n" + "#endif // HEADER_GUARD", + format("#ifndef HEADER_GUARD\n" + " #define HEADER_GUARD\n" + " namespace my_namespace {\n" + "int i;\n" + "} // my_namespace\n" + "#endif // HEADER_GUARD")); } TEST_F(FormatTest, FormatsExternC) { verifyFormat("extern \"C\" {\nint a;"); } |