diff --git a/clang/unittests/Format/FormatTestBase.h b/clang/unittests/Format/FormatTestBase.h index 40442d60aa330..2b0c4550bb951 100644 --- a/clang/unittests/Format/FormatTestBase.h +++ b/clang/unittests/Format/FormatTestBase.h @@ -85,9 +85,11 @@ class FormatTestBase : public ::testing::Test { const std::optional &Style = {}, const std::vector &Ranges = {}) { testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str()); - EXPECT_EQ(Expected.str(), - format(Expected, Style, SC_ExpectComplete, Ranges)) - << "Expected code is not stable"; + if (Expected != Code) { + EXPECT_EQ(Expected.str(), + format(Expected, Style, SC_ExpectComplete, Ranges)) + << "Expected code is not stable"; + } EXPECT_EQ(Expected.str(), format(Code, Style, SC_ExpectComplete, Ranges)); auto UsedStyle = Style ? Style.value() : getDefaultStyle(); if (UsedStyle.Language == FormatStyle::LK_Cpp) {