aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
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.
//===----------------------------------------------------------------------===//