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.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index b52a9fd7c3..daae94bb13 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -373,6 +373,37 @@ TEST_F(FormatTest, StaticInitializers) {
" \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" };");
}
+TEST_F(FormatTest, FormatsSmallMacroDefinitionsInSingleLine) {
+ verifyFormat("#define ALooooooooooooooooooooooooooooooooooooooongMacro("
+ " \\\n"
+ " aLoooooooooooooooooooooooongFuuuuuuuuuuuuuunctiooooooooo)");
+}
+
+TEST_F(FormatTest, BreaksOnHashWhenDirectiveIsInvalid) {
+ EXPECT_EQ("#\n;", format("#;"));
+}
+
+TEST_F(FormatTest, UnescapedEndOfLineEndsPPDirective) {
+ EXPECT_EQ("#line 42 \"test\"\n",
+ format("# \\\n line \\\n 42 \\\n \"test\"\n"));
+ EXPECT_EQ("#define A B\n", format("# \\\n define \\\n A \\\n B\n"));
+}
+
+TEST_F(FormatTest, EndOfFileEndsPPDirective) {
+ EXPECT_EQ("#line 42 \"test\"",
+ format("# \\\n line \\\n 42 \\\n \"test\""));
+ EXPECT_EQ("#define A B", format("# \\\n define \\\n A \\\n B"));
+}
+
+TEST_F(FormatTest, MixingPreprocessorDirectivesAndNormalCode) {
+ verifyFormat("#define ALooooooooooooooooooooooooooooooooooooooongMacro("
+ " \\\n"
+ " aLoooooooooooooooooooooooongFuuuuuuuuuuuuuunctiooooooooo)\n"
+ "\n"
+ "AlooooooooooooooooooooooooooooooooooooooongCaaaaaaaaaal(\n"
+ " aLooooooooooooooooooooooonPaaaaaaaaaaaaaaaaaaaaarmmmm);\n");
+}
+
//===----------------------------------------------------------------------===//
// Line break tests.
//===----------------------------------------------------------------------===//