diff options
Diffstat (limited to 'clang/unittests/Format/FormatTestTextProto.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTestTextProto.cpp | 51 |
1 files changed, 2 insertions, 49 deletions
diff --git a/clang/unittests/Format/FormatTestTextProto.cpp b/clang/unittests/Format/FormatTestTextProto.cpp index 608059c9ea8..4e4387b9d38 100644 --- a/clang/unittests/Format/FormatTestTextProto.cpp +++ b/clang/unittests/Format/FormatTestTextProto.cpp @@ -19,20 +19,12 @@ namespace format { class FormatTestTextProto : public ::testing::Test { protected: - enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete }; - static std::string format(llvm::StringRef Code, unsigned Offset, - unsigned Length, const FormatStyle &Style, - StatusCheck CheckComplete = SC_ExpectComplete) { + unsigned Length, const FormatStyle &Style) { DEBUG(llvm::errs() << "---\n"); DEBUG(llvm::errs() << Code << "\n\n"); std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length)); - FormattingAttemptStatus Status; - tooling::Replacements Replaces = - reformat(Style, Code, Ranges, "<stdin>", &Status); - bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete; - EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete) - << Code << "\n\n"; + tooling::Replacements Replaces = reformat(Style, Code, Ranges); auto Result = applyAllReplacements(Code, Replaces); EXPECT_TRUE(static_cast<bool>(Result)); DEBUG(llvm::errs() << "\n" << *Result << "\n\n"); @@ -53,12 +45,6 @@ protected: Style.ColumnLimit = 60; // To make writing tests easier. verifyFormat(Code, Style); } - - static void verifyIncompleteFormat(llvm::StringRef Code) { - FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto); - EXPECT_EQ(Code.str(), - format(Code, 0, Code.size(), Style, SC_ExpectIncomplete)); - } }; TEST_F(FormatTestTextProto, KeepsTopLevelEntriesFittingALine) { @@ -509,38 +495,5 @@ TEST_F(FormatTestTextProto, PutsMultipleEntriesInExtensionsOnNewlines) { "}", Style); } -TEST_F(FormatTestTextProto, IncompleteFormat) { - verifyIncompleteFormat("data {"); - verifyIncompleteFormat("data <"); - verifyIncompleteFormat("data ["); - verifyIncompleteFormat("data: {"); - verifyIncompleteFormat("data: <"); - verifyIncompleteFormat("data: ["); - verifyIncompleteFormat("key:"); - verifyIncompleteFormat("key:}"); - verifyIncompleteFormat("key: ]"); - verifyIncompleteFormat("key: >"); - verifyIncompleteFormat(": value"); - verifyIncompleteFormat(": {}"); - verifyIncompleteFormat(": <>"); - verifyIncompleteFormat(": []"); - verifyIncompleteFormat("}\n" - "key: value"); - verifyIncompleteFormat("]\n" - "key: value"); - verifyIncompleteFormat("> key: value"); - verifyIncompleteFormat("data { key: {"); - verifyIncompleteFormat("data < key: ["); - verifyIncompleteFormat("data [ key: {"); - verifyIncompleteFormat("> key: value {"); - verifyIncompleteFormat("> key: ["); - verifyIncompleteFormat("}\n" - "key: {"); - verifyIncompleteFormat("data { key: 1 id:"); - verifyIncompleteFormat("}\n" - "key {"); - verifyIncompleteFormat("> <"); -} - } // end namespace tooling } // end namespace clang |

