diff options
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 201a08bb5f..b0f0fdba36 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1625,6 +1625,47 @@ TEST_F(FormatTest, MergeHandlingInTheFaceOfPreprocessorDirectives) { " if (true) continue;", ShortMergedIf); } +TEST_F(FormatTest, BlockCommentsInControlLoops) { + verifyFormat("if (0) /* a comment in a strange place */ {\n" + " f();\n" + "}"); + verifyFormat("if (0) /* a comment in a strange place */ {\n" + " f();\n" + "} /* another comment */ else /* comment #3 */ {\n" + " g();\n" + "}"); + verifyFormat("while (0) /* a comment in a strange place */ {\n" + " f();\n" + "}"); + verifyFormat("for (;;) /* a comment in a strange place */ {\n" + " f();\n" + "}"); + verifyFormat("do /* a comment in a strange place */ {\n" + " f();\n" + "} /* another comment */ while (0);"); +} + +TEST_F(FormatTest, BlockComments) { + EXPECT_EQ("/* */ /* */ /* */\n/* */ /* */ /* */", + format("/* *//* */ /* */\n/* *//* */ /* */")); + EXPECT_EQ("/* */ a /* */ b;", + format(" /* */ a/* */ b;")); + EXPECT_EQ("#define A /* */\\\n" + " b\n" + "/* */\n" + "someCall(\n" + " parameter);", + format("#define A /* */ b\n" + "/* */\n" + "someCall(parameter);", getLLVMStyleWithColumns(15))); + + EXPECT_EQ("#define A\n" + "/* */ someCall(\n" + " parameter);", + format("#define A\n" + "/* */someCall(parameter);", getLLVMStyleWithColumns(15))); +} + //===----------------------------------------------------------------------===// // Objective-C tests. //===----------------------------------------------------------------------===// |