diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-04 07:34:48 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-04 07:34:48 +0000 |
commit | fa543accd8945c39d5128612c8822d0ab4ad594c (patch) | |
tree | 4b4e2e2e1e9f8cf380449591bb1a3f501b35b199 /unittests/Format/FormatTest.cpp | |
parent | 2752ff35854b295837b8088e44d5a932be60e107 (diff) |
Improve formatting of stream operators.
If there are string literals on either side of a '<<', chances are
high that they represent logically separate concepts. Otherwise,
the author could just have just a single literal (possible split
over multiple lines).
So, we can now nicely format things like:
cout << "somepacket = {\n"
<< " val a = " << ValueA << "\n"
<< " val b = " << ValueB << "\n"
<< "}";
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174310 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 17a8dc48ab..3b5256990d 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1289,6 +1289,13 @@ TEST_F(FormatTest, AlignsPipes) { "aaaaaaaa << (aaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" " << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" " << aaaaaaaaaaaaaaaaaaaaaaaaaaaaa;"); + + verifyFormat("return out << \"somepacket = {\\n\"\n" + " << \" aaaaaa = \" << pkt.aaaaaa << \"\\n\"\n" + " << \" bbbb = \" << pkt.bbbb << \"\\n\"\n" + " << \" cccccc = \" << pkt.cccccc << \"\\n\"\n" + " << \" ddd = [\" << pkt.ddd << \"]\\n\"\n" + " << \"}\";"); } TEST_F(FormatTest, UnderstandsEquals) { |