aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-11-07 17:43:07 +0000
committerDaniel Jasper <djasper@google.com>2013-11-07 17:43:07 +0000
commit59875ac81b97de87ac6c4c7cb256ab71b75114f2 (patch)
treed27469871aa405ac1349a7dcb319e4eeca19b8e0 /unittests
parent740265db4f5764782d3486d855bfccfc7d49f194 (diff)
downloadclang-59875ac81b97de87ac6c4c7cb256ab71b75114f2.tar.gz
clang-format: Remove old hack that mainly made incorrect tests pass.
As a side-effect, constructors definitions will correctly be recognized and formatted as function declarations. Tests will be added in a follow-up patch actually using the correct recognition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194209 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTest.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 00c684cc40..43f5634131 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -2500,9 +2500,11 @@ TEST_F(FormatTest, PutEmptyBlocksIntoOneLine) {
TEST_F(FormatTest, PreventConfusingIndents) {
verifyFormat(
- "SomeLongMethodName(SomeReallyLongMethod(CallOtherReallyLongMethod(\n"
- " parameter, parameter, parameter)),\n"
- " SecondLongCall(parameter));");
+ "void f() {\n"
+ " SomeLongMethodName(SomeReallyLongMethod(CallOtherReallyLongMethod(\n"
+ " parameter, parameter, parameter)),\n"
+ " SecondLongCall(parameter));\n"
+ "}");
verifyFormat(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaa(\n"
@@ -3078,8 +3080,10 @@ TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) {
verifyFormat("aaaaaaaaaaaaaaa(aaaaaaaaa, aaaaaaaaa, aaaaaaaaaaaaaaaaaaaaa)\n"
" .aaaaaaaaaaaaaaaaaa();",
NoBinPacking);
- verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
- " aaaaaaaaaa, aaaaaaaaaa, aaaaaaaaaa, aaaaaaaaaaa);",
+ verifyFormat("void f() {\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaa, aaaaaaaaaa, aaaaaaaaaa, aaaaaaaaaaa);\n"
+ "}",
NoBinPacking);
verifyFormat(
@@ -3168,7 +3172,8 @@ TEST_F(FormatTest, FormatsBuilderPattern) {
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
" ->aaaaaaaaaaaaaaaaa();");
verifyGoogleFormat(
- "someobj->Add((new util::filetools::Handler(dir))\n"
+ "void f() {\n"
+ " someo->Add((new util::filetools::Handler(dir))\n"
" ->OnEvent1(NewPermanentCallback(\n"
" this, &HandlerHolderClass::EventHandlerCBA))\n"
" ->OnEvent2(NewPermanentCallback(\n"
@@ -3178,7 +3183,8 @@ TEST_F(FormatTest, FormatsBuilderPattern) {
" ->OnEvent5(NewPermanentCallback(\n"
" this, &HandlerHolderClass::EventHandlerCBD))\n"
" ->OnEvent6(NewPermanentCallback(\n"
- " this, &HandlerHolderClass::EventHandlerCBE)));");
+ " this, &HandlerHolderClass::EventHandlerCBE)));\n"
+ "}");
verifyFormat(
"aaaaaaaaaaa().aaaaaaaaaaa().aaaaaaaaaaa().aaaaaaaaaaa().aaaaaaaaaaa();");
@@ -3638,8 +3644,10 @@ TEST_F(FormatTest, WrapsAtFunctionCallsIfNecessary) {
verifyFormat("aaaaa(aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa).aaaaa(aaaaa),\n"
" aaaaaaaaaaaaaaaaaaaaa);");
- verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaa(\n"
- " aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaaa());");
+ verifyFormat("void f() {\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaaa());\n"
+ "}");
verifyFormat(
"aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
@@ -3723,8 +3731,10 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) {
"aaaaaaaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
- verifyFormat("a<aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa>(\n"
- " a(aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa));");
+ verifyFormat("void f() {\n"
+ " a<aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa>(\n"
+ " a(aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa));\n"
+ "}");
verifyFormat("template <typename T> class C {};");
verifyFormat("template <typename T> void f();");
@@ -4252,6 +4262,9 @@ TEST_F(FormatTest, BreaksLongDeclarations) {
verifyFormat("typedef LoooooooooooooooooooooooooooooooooooooooongType\n"
" AnotherNameForTheLongType;",
getGoogleStyle());
+ verifyFormat("typedef LongTemplateType<aaaaaaaaaaaaaaaaaaa()>\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;",
+ getGoogleStyle());
verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType\n"
" LoooooooooooooooooooooooooooooooooooooooongVariable;",
getGoogleStyle());