From f83834feb15845bb85cefa892efcad7ec3d07e2c Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 2 Nov 2015 20:02:49 +0000 Subject: clang-format: Simplify and improve stop condition for formatting unaffected lines with incorrect initial indent. Starting from: namespace { int i; // There shouldn't be indentation here. int j; // <- call clang-format on this line. } Before: namespace { int i; int j; } After: namespace { int i; int j; } llvm-svn: 251824 --- clang/unittests/Format/FormatTestSelective.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'clang/unittests/Format/FormatTestSelective.cpp') diff --git a/clang/unittests/Format/FormatTestSelective.cpp b/clang/unittests/Format/FormatTestSelective.cpp index 9c4d1c3d2b0..d53d1c04292 100644 --- a/clang/unittests/Format/FormatTestSelective.cpp +++ b/clang/unittests/Format/FormatTestSelective.cpp @@ -273,6 +273,27 @@ TEST_F(FormatTestSelective, IndividualStatementsOfNestedBlocks) { 0, 0)); } +TEST_F(FormatTestSelective, WrongIndent) { + EXPECT_EQ("namespace {\n" + "int i;\n" + "int j;\n" + "}", + format("namespace {\n" + " int i;\n" // Format here. + " int j;\n" + "}", + 15, 0)); + EXPECT_EQ("namespace {\n" + " int i;\n" + " int j;\n" + "}", + format("namespace {\n" + " int i;\n" + " int j;\n" // Format here. + "}", + 24, 0)); +} + TEST_F(FormatTestSelective, AlwaysFormatsEntireMacroDefinitions) { Style.AlignEscapedNewlinesLeft = true; EXPECT_EQ("int i;\n" -- cgit v1.2.3