aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-04-25 08:56:26 +0000
committerDaniel Jasper <djasper@google.com>2013-04-25 08:56:26 +0000
commit2972d049637349bb82f52a27ad3337cf4ab769b4 (patch)
treed4dc0797bebb5d5fb4ae934f2fe4268c5784f257 /unittests
parentf1ed9febdd4bc4746c2a9fdaa0700014900b1326 (diff)
Add option to align escaped newlines left.
This enables formattings like: #define A \ int aaaa; \ int b; \ int ccc; \ int dddddddddd; Enabling this for Google/Chromium styles only as I don't know whether it is desired for Clang/LLVM. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180253 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTest.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 97539d91a6..97d4df8e5e 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -2974,16 +2974,16 @@ TEST_F(FormatTest, MergeHandlingInTheFaceOfPreprocessorDirectives) {
format("if (true)\nreturn 42;", AllowsMergedIf));
FormatStyle ShortMergedIf = AllowsMergedIf;
ShortMergedIf.ColumnLimit = 25;
- verifyFormat("#define A \\\n"
+ verifyFormat("#define A \\\n"
" if (true) return 42;",
ShortMergedIf);
- verifyFormat("#define A \\\n"
- " f(); \\\n"
+ verifyFormat("#define A \\\n"
+ " f(); \\\n"
" if (true)\n"
"#define B",
ShortMergedIf);
- verifyFormat("#define A \\\n"
- " f(); \\\n"
+ verifyFormat("#define A \\\n"
+ " f(); \\\n"
" if (true)\n"
"g();",
ShortMergedIf);
@@ -3800,6 +3800,15 @@ TEST_F(FormatTest, BreakStringLiterals) {
"\"pathat/\"\n"
"\"slashes\"",
format("\"split/pathat/slashes\"", getLLVMStyleWithColumns(10)));
+
+ FormatStyle AlignLeft = getLLVMStyleWithColumns(12);
+ AlignLeft.AlignEscapedNewlinesLeft = true;
+ EXPECT_EQ(
+ "#define A \\\n"
+ " \"some \" \\\n"
+ " \"text \" \\\n"
+ " \"other\";",
+ format("#define A \"some text other\";", AlignLeft));
}
TEST_F(FormatTest, DoNotBreakStringLiteralsInEscapeSequence) {