Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -38,7 +38,8 @@ std::string format(llvm::StringRef Code, const FormatStyle &Style = getLLVMStyle(), - StatusCheck CheckComplete = SC_ExpectComplete) { + StatusCheck CheckComplete = SC_ExpectComplete, + bool check = true) { LLVM_DEBUG(llvm::errs() << "---\n"); LLVM_DEBUG(llvm::errs() << Code << "\n\n"); std::vector Ranges(1, tooling::Range(0, Code.size())); @@ -54,6 +55,12 @@ auto Result = applyAllReplacements(Code, Replaces); EXPECT_TRUE(static_cast(Result)); LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n"); + if (check && Status.FormatComplete) { + // Do recursive call and check that format of format is valid. + LLVM_DEBUG(llvm::errs() << "\ncheck\n\n"); + auto FormatedResult = format(*Result, Style, SC_ExpectComplete, false); + EXPECT_EQ(*Result, FormatedResult); + } return *Result; }