summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-07-12 11:37:05 +0000
committerDaniel Jasper <djasper@google.com>2013-07-12 11:37:05 +0000
commit5aad4e56141d069b4298c330ff359c6d412b8585 (patch)
tree23ffa357610f2a694432aa56d5d5f5e147ff221a /clang/unittests/Format/FormatTest.cpp
parentaea3bde06baf04ccb063037e083646991c96716c (diff)
downloadbcm5719-llvm-5aad4e56141d069b4298c330ff359c6d412b8585.tar.gz
bcm5719-llvm-5aad4e56141d069b4298c330ff359c6d412b8585.zip
clang-format: Fix string literal breaking.
Before this patch, it did not cooperate with Style::AlwaysBreakBeforeMultilineStrings. Thus, it would turn aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa"); into: aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa"); and only a second format step would lead to the desired (with that option): aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa"); This could even lead to clang-format breaking the string at a different character and thus leading to a completely different end result. llvm-svn: 186154
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 50f033ccabb..4ca5bb49b60 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4958,6 +4958,16 @@ TEST_F(FormatTest, BreakStringLiterals) {
"rs\"",
getLLVMStyleWithColumns(20)));
+ // Verify that splitting the strings understands
+ // Style::AlwaysBreakBeforeMultilineStrings.
+ EXPECT_EQ("aaaaaaaaaaaa(aaaaaaaaaaaaa,\n"
+ " \"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa \"\n"
+ " \"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa\");",
+ format("aaaaaaaaaaaa(aaaaaaaaaaaaa, \"aaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaa\");",
+ getGoogleStyle()));
+
FormatStyle AlignLeft = getLLVMStyleWithColumns(12);
AlignLeft.AlignEscapedNewlinesLeft = true;
EXPECT_EQ(
OpenPOWER on IntegriCloud