diff options
| author | 2017-10-04 20:27:34 +0000 | |
|---|---|---|
| committer | 2017-10-04 20:27:34 +0000 | |
| commit | 31eb748944903b7f4f38afda9851951ca9dfc1ae (patch) | |
| tree | 9b95b6ea45d0874d75eb05b90c0840e191416439 /gnu/llvm/tools/clang/unittests/Format/FormatTestSelective.cpp | |
| parent | Don't try to handle IPv4-compatible IPv6 addresses (diff) | |
| download | wireguard-openbsd-31eb748944903b7f4f38afda9851951ca9dfc1ae.tar.xz wireguard-openbsd-31eb748944903b7f4f38afda9851951ca9dfc1ae.zip | |
Import LLVM 5.0.0 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/tools/clang/unittests/Format/FormatTestSelective.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/unittests/Format/FormatTestSelective.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/gnu/llvm/tools/clang/unittests/Format/FormatTestSelective.cpp b/gnu/llvm/tools/clang/unittests/Format/FormatTestSelective.cpp index 2bc60fd1e0d..182218fe96d 100644 --- a/gnu/llvm/tools/clang/unittests/Format/FormatTestSelective.cpp +++ b/gnu/llvm/tools/clang/unittests/Format/FormatTestSelective.cpp @@ -24,10 +24,10 @@ protected: DEBUG(llvm::errs() << "---\n"); DEBUG(llvm::errs() << Code << "\n\n"); std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length)); - bool IncompleteFormat = false; + FormattingAttemptStatus Status; tooling::Replacements Replaces = - reformat(Style, Code, Ranges, "<stdin>", &IncompleteFormat); - EXPECT_FALSE(IncompleteFormat) << Code << "\n\n"; + reformat(Style, Code, Ranges, "<stdin>", &Status); + EXPECT_TRUE(Status.FormatComplete) << Code << "\n\n"; auto Result = applyAllReplacements(Code, Replaces); EXPECT_TRUE(static_cast<bool>(Result)); DEBUG(llvm::errs() << "\n" << *Result << "\n\n"); @@ -111,13 +111,19 @@ TEST_F(FormatTestSelective, FormatsCommentsLocally) { format("int a; // comment\n" "int b; // comment", 0, 0)); - EXPECT_EQ("int a; // comment\n" - " // line 2\n" + EXPECT_EQ("int a; // comment\n" + " // line 2\n" "int b;", format("int a; // comment\n" " // line 2\n" "int b;", 28, 0)); + EXPECT_EQ("int a; // comment\n" + "// comment 2\n" + "int b;", + format("int a; // comment\n" + "// comment 2\n" + "int b;", 28, 0)); EXPECT_EQ("int aaaaaa; // comment\n" "int b;\n" "int c; // unrelated comment", @@ -319,7 +325,7 @@ TEST_F(FormatTestSelective, WrongIndent) { } TEST_F(FormatTestSelective, AlwaysFormatsEntireMacroDefinitions) { - Style.AlignEscapedNewlinesLeft = true; + Style.AlignEscapedNewlines = FormatStyle::ENAS_Left; EXPECT_EQ("int i;\n" "#define A \\\n" " int i; \\\n" @@ -461,7 +467,7 @@ TEST_F(FormatTestSelective, ReformatRegionAdjustsIndent) { TEST_F(FormatTestSelective, UnderstandsTabs) { Style.IndentWidth = 8; Style.UseTab = FormatStyle::UT_Always; - Style.AlignEscapedNewlinesLeft = true; + Style.AlignEscapedNewlines = FormatStyle::ENAS_Left; EXPECT_EQ("void f() {\n" "\tf();\n" "\tg();\n" @@ -524,6 +530,14 @@ TEST_F(FormatTestSelective, SelectivelyRequoteJavaScript) { 20, 0)); } +TEST_F(FormatTestSelective, KeepsIndentAfterCommentSectionImport) { + std::string Code = "#include <a> // line 1\n" // 23 chars long + " // line 2\n" // 23 chars long + "\n" // this newline is char 47 + "int i;"; // this line is not indented + EXPECT_EQ(Code, format(Code, 47, 1)); +} + } // end namespace } // end namespace format } // end namespace clang |
