diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-06 14:22:40 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-06 14:22:40 +0000 |
commit | 8ff690ab478b33e0d830a6203de12d191d94f8ff (patch) | |
tree | af093e6e11e4cdec73d16e5268f690f720f66113 /unittests/Format/FormatTest.cpp | |
parent | 6b5ba8be528bf614d5f4477a4cdbd7c3b19714a6 (diff) |
Optionally derive formatting information from the input file.
With this patch, clang-format can analyze the input file for two
properties:
1. Is "int *a" or "int* a" more common.
2. Are non-C++03 constructs used, e.g. A<A<A>>.
With Google-style, clang-format will now use the more common style for
(1) and format C++03 compatible, unless it finds C++11 constructs in the
input.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174504 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index f5250bc4df..0f469836f5 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1437,6 +1437,11 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) { verifyGoogleFormat("A<A<int>> a;"); verifyGoogleFormat("A<A<A<int>>> a;"); verifyGoogleFormat("A<A<A<A<int>>>> a;"); + verifyGoogleFormat("A<A<int> > a;"); + verifyGoogleFormat("A<A<A<int> > > a;"); + verifyGoogleFormat("A<A<A<A<int> > > > a;"); + EXPECT_EQ("A<A<A<A>>> a;", format("A<A<A<A> >> a;", getGoogleStyle())); + EXPECT_EQ("A<A<A<A>>> a;", format("A<A<A<A>> > a;", getGoogleStyle())); verifyFormat("test >> a >> b;"); verifyFormat("test << a >> b;"); @@ -1597,6 +1602,22 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("A = new SomeType *[Length]();"); verifyGoogleFormat("A = new SomeType* [Length]();"); + + EXPECT_EQ("int *a;\n" + "int *a;\n" + "int *a;", format("int *a;\n" + "int* a;\n" + "int *a;", getGoogleStyle())); + EXPECT_EQ("int* a;\n" + "int* a;\n" + "int* a;", format("int* a;\n" + "int* a;\n" + "int *a;", getGoogleStyle())); + EXPECT_EQ("int *a;\n" + "int *a;\n" + "int *a;", format("int *a;\n" + "int * a;\n" + "int * a;", getGoogleStyle())); } TEST_F(FormatTest, FormatsBinaryOperatorsPrecedingEquals) { |