From aa1c920db85e7ac07d09b80eedc66bae7e358f26 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 5 Dec 2012 14:57:28 +0000 Subject: Indentation fixes for clang-format. - Fix behavior of memoization together with optimization - Correctly attribute the PenaltyIndentLevel (breaking directly after "(" did not count towards the inner level) - Recognize more tokens as assignments Review: http://llvm-reviews.chandlerc.com/D172 llvm-svn: 169384 --- clang/unittests/Format/FormatTest.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'clang/unittests/Format/FormatTest.cpp') diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index be4363353e6..c9860d595ce 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -110,6 +110,7 @@ TEST_F(FormatTest, FormatIfWithoutCompountStatement) { verifyFormat("if (true)\n f();\ng();"); verifyFormat("if (a)\n if (b)\n if (c)\n g();\nh();"); verifyFormat("if (a)\n if (b) {\n f();\n }\ng();"); + EXPECT_EQ("if (a)\n // comment\n f();", format("if(a)\n// comment\nf();")); } TEST_F(FormatTest, ParseIfThenElse) { @@ -277,6 +278,17 @@ TEST_F(FormatTest, BreaksDesireably) { " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)),\n" " aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)));"); + + verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n" + " (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); + + // This test case breaks on an incorrect memoization, i.e. an optimization not + // taking into account the StopAt value. + verifyFormat( + "return aaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaa ||\n" + " aaaaaaaaaaa(aaaaaaaaa) || aaaaaaaaaaaaaaaaaaaaaaa ||\n" + " aaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaa ||\n" + " (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); } TEST_F(FormatTest, AlignsStringLiterals) { @@ -350,6 +362,10 @@ TEST_F(FormatTest, UnderstandsUsesOfStar) { verifyFormat("int a = b * 10;"); verifyFormat("int a = 10 * b;"); verifyFormat("int a = b * c;"); + verifyFormat("int a += b * c;"); + verifyFormat("int a -= b * c;"); + verifyFormat("int a *= b * c;"); + verifyFormat("int a /= b * c;"); verifyFormat("int a = *b;"); verifyFormat("int a = *b * c;"); verifyFormat("int a = b * *c;"); -- cgit v1.2.3