aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2012-12-17 11:29:41 +0000
committerDaniel Jasper <djasper@google.com>2012-12-17 11:29:41 +0000
commit05b1ac8791ee89fdf0b275631ab8118febc7c33d (patch)
tree0932ed10ab7b43606b21e78a7ee848fb9b5d8c98 /unittests/Format/FormatTest.cpp
parent728e2127e858611750d560ee7692c322a8570faa (diff)
Fix several formatting problems.
More specifically: - Improve formatting of static initializers. - Fix formatting of lines comments in enums. - Fix formmating of trailing line comments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170316 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index d70442cebf..5ce1022d86 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -245,6 +245,19 @@ TEST_F(FormatTest, UnderstandsSingleLineComments) {
EXPECT_EQ("int i // This is a fancy variable\n = 5;",
format("int i // This is a fancy variable\n= 5;"));
+ EXPECT_EQ("enum E {\n"
+ " // comment\n"
+ " VAL_A, // comment\n"
+ " VAL_B\n"
+ "};",
+ format("enum E{\n// comment\nVAL_A,// comment\nVAL_B};"));
+
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
+ " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; // Trailing comment");
+}
+
+TEST_F(FormatTest, UnderstandsMultiLineComments) {
verifyFormat("f(/*test=*/ true);");
}
@@ -319,6 +332,15 @@ TEST_F(FormatTest, FormatsNamespaces) {
"}");
}
+TEST_F(FormatTest, StaticInitializers) {
+ verifyFormat("static SomeClass SC = { 1, 'a' };");
+
+ // FIXME: Format like enums if the static initializer does not fit on a line.
+ verifyFormat(
+ "static SomeClass WithALoooooooooooooooooooongName = { 100000000,\n"
+ " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" };");
+}
+
//===----------------------------------------------------------------------===//
// Line break tests.
//===----------------------------------------------------------------------===//