[clang] 20b4df1 - [clang-format][NFC] Clean up unit tests

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 16 16:03:27 PDT 2023


Author: Owen Pan
Date: 2023-06-16T16:03:19-07:00
New Revision: 20b4df1ed611517d2c964dbade3e61aff4be2e87

URL: https://github.com/llvm/llvm-project/commit/20b4df1ed611517d2c964dbade3e61aff4be2e87
DIFF: https://github.com/llvm/llvm-project/commit/20b4df1ed611517d2c964dbade3e61aff4be2e87.diff

LOG: [clang-format][NFC] Clean up unit tests

This patch adds a verifyNoChange macro to verify code that won't
change after being formatted. (The code will not be messed up before
being formatted.) It then replaces EXPECT_EQ with verifyFormat
wherever applicable so that the code will be messed up before being
formatted. When the replacement fails the unit test, verifyFormat is
replaced with verifyNoChange.

Differential Revision: https://reviews.llvm.org/D153109

Added: 
    

Modified: 
    clang/unittests/Format/FormatTest.cpp
    clang/unittests/Format/FormatTestBase.h
    clang/unittests/Format/FormatTestComments.cpp
    clang/unittests/Format/FormatTestJS.cpp
    clang/unittests/Format/FormatTestJava.cpp
    clang/unittests/Format/QualifierFixerTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index ee64b3a041c38..61619fcd76169 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -38,9 +38,7 @@ TEST_F(FormatTest, LLVMStyleOverride) {
 // Basic function tests.
 //===----------------------------------------------------------------------===//
 
-TEST_F(FormatTest, DoesNotChangeCorrectlyFormattedCode) {
-  EXPECT_EQ(";", format(";"));
-}
+TEST_F(FormatTest, DoesNotChangeCorrectlyFormattedCode) { verifyFormat(";"); }
 
 TEST_F(FormatTest, FormatsGlobalStatementsAt0) {
   EXPECT_EQ("int i;", format("  int i;"));
@@ -5159,7 +5157,7 @@ TEST_F(FormatTest, UnderstandsLinePPDirective) {
 }
 
 TEST_F(FormatTest, LayoutUnknownPPDirective) {
-  EXPECT_EQ("#;", format("#;"));
+  verifyFormat("#;");
   verifyFormat("#\n;\n;\n;");
 }
 
@@ -5492,7 +5490,7 @@ TEST_F(FormatTest, HandlePreprocessorDirectiveContext) {
                    getLLVMStyleWithColumns(13)));
 }
 
-TEST_F(FormatTest, LayoutSingleHash) { EXPECT_EQ("#\na;", format("#\na;")); }
+TEST_F(FormatTest, LayoutSingleHash) { verifyFormat("#\na;"); }
 
 TEST_F(FormatTest, LayoutCodeInMacroDefinitions) {
   EXPECT_EQ("#define A    \\\n"
@@ -5504,7 +5502,7 @@ TEST_F(FormatTest, LayoutCodeInMacroDefinitions) {
                    getLLVMStyleWithColumns(14)));
 }
 
-TEST_F(FormatTest, LayoutRemainingTokens) { EXPECT_EQ("{}", format("{}")); }
+TEST_F(FormatTest, LayoutRemainingTokens) { verifyFormat("{}"); }
 
 TEST_F(FormatTest, MacroDefinitionInsideStatement) {
   EXPECT_EQ("int x,\n"
@@ -5514,14 +5512,14 @@ TEST_F(FormatTest, MacroDefinitionInsideStatement) {
 }
 
 TEST_F(FormatTest, HashInMacroDefinition) {
-  EXPECT_EQ("#define A(c) L#c", format("#define A(c) L#c", getLLVMStyle()));
-  EXPECT_EQ("#define A(c) u#c", format("#define A(c) u#c", getLLVMStyle()));
-  EXPECT_EQ("#define A(c) U#c", format("#define A(c) U#c", getLLVMStyle()));
-  EXPECT_EQ("#define A(c) u8#c", format("#define A(c) u8#c", getLLVMStyle()));
-  EXPECT_EQ("#define A(c) LR#c", format("#define A(c) LR#c", getLLVMStyle()));
-  EXPECT_EQ("#define A(c) uR#c", format("#define A(c) uR#c", getLLVMStyle()));
-  EXPECT_EQ("#define A(c) UR#c", format("#define A(c) UR#c", getLLVMStyle()));
-  EXPECT_EQ("#define A(c) u8R#c", format("#define A(c) u8R#c", getLLVMStyle()));
+  verifyFormat("#define A(c) L#c", getLLVMStyle());
+  verifyFormat("#define A(c) u#c", getLLVMStyle());
+  verifyFormat("#define A(c) U#c", getLLVMStyle());
+  verifyFormat("#define A(c) u8#c", getLLVMStyle());
+  verifyFormat("#define A(c) LR#c", getLLVMStyle());
+  verifyFormat("#define A(c) uR#c", getLLVMStyle());
+  verifyFormat("#define A(c) UR#c", getLLVMStyle());
+  verifyFormat("#define A(c) u8R#c", getLLVMStyle());
   verifyFormat("#define A \\\n  b #c;", getLLVMStyleWithColumns(11));
   verifyFormat("#define A  \\\n"
                "  {        \\\n"
@@ -5541,8 +5539,8 @@ TEST_F(FormatTest, HashInMacroDefinition) {
 }
 
 TEST_F(FormatTest, RespectWhitespaceInMacroDefinitions) {
-  EXPECT_EQ("#define A (x)", format("#define A (x)"));
-  EXPECT_EQ("#define A(x)", format("#define A(x)"));
+  verifyFormat("#define A (x)");
+  verifyFormat("#define A(x)");
 
   FormatStyle Style = getLLVMStyle();
   Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
@@ -5669,7 +5667,7 @@ TEST_F(FormatTest, MacrosWithoutTrailingSemicolon) {
                    "} // namespace"));
   // Only if the identifier contains at least 5 characters.
   EXPECT_EQ("HTTP f();", format("HTTP\nf();"));
-  EXPECT_EQ("MACRO\nf();", format("MACRO\nf();"));
+  verifyNoChange("MACRO\nf();");
   // Only if everything is upper case.
   EXPECT_EQ("class A : public QObject {\n"
             "  Q_Object A() {}\n"
@@ -6099,7 +6097,7 @@ TEST_F(FormatTest, IndentPreprocessorDirectives) {
                            "#  define C 0\n"
                            "#endif";
     EXPECT_EQ(Expected, format(ToFormat, Style));
-    EXPECT_EQ(Expected, format(Expected, Style));
+    verifyFormat(Expected, Style);
   }
   // Keep block quotes aligned.
   {
@@ -6126,7 +6124,7 @@ TEST_F(FormatTest, IndentPreprocessorDirectives) {
                            "#  define C 0\n"
                            "#endif";
     EXPECT_EQ(Expected, format(ToFormat, Style));
-    EXPECT_EQ(Expected, format(Expected, Style));
+    verifyNoChange(Expected, Style);
   }
   // Keep comments aligned with un-indented directives.
   {
@@ -6149,7 +6147,7 @@ TEST_F(FormatTest, IndentPreprocessorDirectives) {
                            "   // Code. Not aligned with #\n"
                            "#define C 0\n";
     EXPECT_EQ(Expected, format(ToFormat, Style));
-    EXPECT_EQ(Expected, format(Expected, Style));
+    verifyFormat(Expected, Style);
   }
   // Test AfterHash with tabs.
   {
@@ -6236,7 +6234,7 @@ TEST_F(FormatTest, IndentPreprocessorDirectives) {
                            "#endif\n"
                            "}";
     EXPECT_EQ(Expected, format(ToFormat, Style));
-    EXPECT_EQ(Expected, format(Expected, Style));
+    verifyFormat(Expected, Style);
   }
   {
     const char *Expected = "void f() {\n"
@@ -6266,7 +6264,7 @@ TEST_F(FormatTest, IndentPreprocessorDirectives) {
                            "#endif\n"
                            "}";
     EXPECT_EQ(Expected, format(ToFormat, Style));
-    EXPECT_EQ(Expected, format(Expected, Style));
+    verifyNoChange(Expected, Style);
   }
 
   // Test single comment before preprocessor
@@ -6432,7 +6430,7 @@ TEST_F(FormatTest, EscapedNewlines) {
   EXPECT_EQ("#define A\n\nint i;", format("#define A \\\n\n int i;"));
   EXPECT_EQ("template <class T> f();", format("\\\ntemplate <class T> f();"));
   EXPECT_EQ("/* \\  \\  \\\n */", format("\\\n/* \\  \\  \\\n */"));
-  EXPECT_EQ("<a\n\\\\\n>", format("<a\n\\\\\n>"));
+  verifyNoChange("<a\n\\\\\n>");
 
   FormatStyle AlignLeft = getLLVMStyle();
   AlignLeft.AlignEscapedNewlines = FormatStyle::ENAS_Left;
@@ -6450,7 +6448,7 @@ TEST_F(FormatTest, EscapedNewlines) {
   EXPECT_EQ("#define A\r\n\r\nint i;", format("#define A \\\r\n\r\n int i;"));
   EXPECT_EQ("template <class T> f();", format("\\\ntemplate <class T> f();"));
   EXPECT_EQ("/* \\  \\  \\\r\n */", format("\\\r\n/* \\  \\  \\\r\n */"));
-  EXPECT_EQ("<a\r\n\\\\\r\n>", format("<a\r\n\\\\\r\n>"));
+  verifyNoChange("<a\r\n\\\\\r\n>");
   EXPECT_EQ("#define MACRO(x) \\\r\n"
             "private:         \\\r\n"
             "  int x(int a);\r\n",
@@ -6791,7 +6789,7 @@ TEST_F(FormatTest, FormatNestedBlocksInMacros) {
 }
 
 TEST_F(FormatTest, PutEmptyBlocksIntoOneLine) {
-  EXPECT_EQ("{}", format("{}"));
+  verifyFormat("{}");
   verifyFormat("enum E {};");
   verifyFormat("enum E {}");
   FormatStyle Style = getLLVMStyle();
@@ -12358,14 +12356,6 @@ TEST_F(FormatTest, FormatsAccessModifiers) {
                "};\n",
                Style);
   verifyFormat("struct foo { /* comment */\n"
-               "private:\n"
-               "  int i;\n"
-               "  // comment\n"
-               "\n"
-               "private:\n"
-               "  int j;\n"
-               "};\n",
-               "struct foo { /* comment */\n"
                "private:\n"
                "  int i;\n"
                "  // comment\n"
@@ -14504,8 +14494,7 @@ TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
 }
 
 TEST_F(FormatTest, DoNotInterfereWithErrorAndWarning) {
-  EXPECT_EQ("#error Leave     all         white!!!!! space* alone!\n",
-            format("#error Leave     all         white!!!!! space* alone!\n"));
+  verifyNoChange("#error Leave     all         white!!!!! space* alone!\n");
   EXPECT_EQ(
       "#warning Leave     all         white!!!!! space* alone!\n",
       format("#warning Leave     all         white!!!!! space* alone!\n"));
@@ -14656,8 +14645,7 @@ TEST_F(FormatTest, FormatForObjectiveCMethodDecls) {
             format("-(NSInteger)Method4:(id)anObject;"));
   EXPECT_EQ("- (NSInteger)Method5:(id)anObject:(id)AnotherObject;",
             format("-(NSInteger)Method5:(id)anObject:(id)AnotherObject;"));
-  EXPECT_EQ("- (id)Method6:(id)A:(id)B:(id)C:(id)D;",
-            format("- (id)Method6:(id)A:(id)B:(id)C:(id)D;"));
+  verifyFormat("- (id)Method6:(id)A:(id)B:(id)C:(id)D;");
   EXPECT_EQ("- (void)sendAction:(SEL)aSelector to:(id)anObject "
             "forAllCells:(BOOL)flag;",
             format("- (void)sendAction:(SEL)aSelector to:(id)anObject "
@@ -14732,10 +14720,8 @@ TEST_F(FormatTest, BreaksStringLiterals) {
       "  \"other\";",
       format("#define A \"so text other\";", getLLVMStyleWithColumns(12)));
 
-  EXPECT_EQ("\"some text\"",
-            format("\"some text\"", getLLVMStyleWithColumns(1)));
-  EXPECT_EQ("\"some text\"",
-            format("\"some text\"", getLLVMStyleWithColumns(11)));
+  verifyFormat("\"some text\"", getLLVMStyleWithColumns(1));
+  verifyFormat("\"some text\"", getLLVMStyleWithColumns(11));
   EXPECT_EQ("\"some \"\n"
             "\"text\"",
             format("\"some text\"", getLLVMStyleWithColumns(10)));
@@ -14861,7 +14847,7 @@ TEST_F(FormatTest, BreaksStringLiterals) {
 
   FormatStyle Style = getLLVMStyleWithColumns(12);
   Style.BreakStringLiterals = false;
-  EXPECT_EQ("\"some text other\";", format("\"some text other\";", Style));
+  verifyFormat("\"some text other\";", Style);
 
   FormatStyle AlignLeft = getLLVMStyleWithColumns(12);
   AlignLeft.AlignEscapedNewlines = FormatStyle::ENAS_Left;
@@ -14925,12 +14911,11 @@ TEST_F(FormatTest, BreaksWideAndNSStringLiterals) {
 
 TEST_F(FormatTest, DoesNotBreakRawStringLiterals) {
   FormatStyle Style = getGoogleStyleWithColumns(15);
-  EXPECT_EQ("R\"x(raw literal)x\";", format("R\"x(raw literal)x\";", Style));
-  EXPECT_EQ("uR\"x(raw literal)x\";", format("uR\"x(raw literal)x\";", Style));
-  EXPECT_EQ("LR\"x(raw literal)x\";", format("LR\"x(raw literal)x\";", Style));
-  EXPECT_EQ("UR\"x(raw literal)x\";", format("UR\"x(raw literal)x\";", Style));
-  EXPECT_EQ("u8R\"x(raw literal)x\";",
-            format("u8R\"x(raw literal)x\";", Style));
+  verifyFormat("R\"x(raw literal)x\";", Style);
+  verifyFormat("uR\"x(raw literal)x\";", Style);
+  verifyFormat("LR\"x(raw literal)x\";", Style);
+  verifyFormat("UR\"x(raw literal)x\";", Style);
+  verifyFormat("u8R\"x(raw literal)x\";", Style);
 }
 
 TEST_F(FormatTest, BreaksStringLiteralsWithin_TMacro) {
@@ -15210,8 +15195,8 @@ TEST_F(FormatTest, BreakStringLiteralsBeforeUnbreakableTokenSequence) {
 }
 
 TEST_F(FormatTest, DoNotBreakStringLiteralsInEscapeSequence) {
-  EXPECT_EQ("\"\\a\"", format("\"\\a\"", getLLVMStyleWithColumns(3)));
-  EXPECT_EQ("\"\\\"", format("\"\\\"", getLLVMStyleWithColumns(2)));
+  verifyFormat("\"\\a\"", getLLVMStyleWithColumns(3));
+  verifyFormat("\"\\\"", getLLVMStyleWithColumns(2));
   EXPECT_EQ("\"test\"\n"
             "\"\\n\"",
             format("\"test\\n\"", getLLVMStyleWithColumns(7)));
@@ -15221,19 +15206,16 @@ TEST_F(FormatTest, DoNotBreakStringLiteralsInEscapeSequence) {
   EXPECT_EQ("\"\\\\\\\\\"\n"
             "\"\\n\"",
             format("\"\\\\\\\\\\n\"", getLLVMStyleWithColumns(7)));
-  EXPECT_EQ("\"\\uff01\"", format("\"\\uff01\"", getLLVMStyleWithColumns(7)));
+  verifyFormat("\"\\uff01\"", getLLVMStyleWithColumns(7));
   EXPECT_EQ("\"\\uff01\"\n"
             "\"test\"",
             format("\"\\uff01test\"", getLLVMStyleWithColumns(8)));
-  EXPECT_EQ("\"\\Uff01ff02\"",
-            format("\"\\Uff01ff02\"", getLLVMStyleWithColumns(11)));
+  verifyFormat("\"\\Uff01ff02\"", getLLVMStyleWithColumns(11));
   EXPECT_EQ("\"\\x000000000001\"\n"
             "\"next\"",
             format("\"\\x000000000001next\"", getLLVMStyleWithColumns(16)));
-  EXPECT_EQ("\"\\x000000000001next\"",
-            format("\"\\x000000000001next\"", getLLVMStyleWithColumns(15)));
-  EXPECT_EQ("\"\\x000000000001\"",
-            format("\"\\x000000000001\"", getLLVMStyleWithColumns(7)));
+  verifyFormat("\"\\x000000000001next\"", getLLVMStyleWithColumns(15));
+  verifyFormat("\"\\x000000000001\"", getLLVMStyleWithColumns(7));
   EXPECT_EQ("\"test\"\n"
             "\"\\000000\"\n"
             "\"000001\"",
@@ -21054,11 +21036,9 @@ TEST_F(FormatTest, WorksFor8bitEncodings) {
 }
 
 TEST_F(FormatTest, HandlesUTF8BOM) {
-  EXPECT_EQ("\xef\xbb\xbf", format("\xef\xbb\xbf"));
-  EXPECT_EQ("\xef\xbb\xbf#include <iostream>",
-            format("\xef\xbb\xbf#include <iostream>"));
-  EXPECT_EQ("\xef\xbb\xbf\n#include <iostream>",
-            format("\xef\xbb\xbf\n#include <iostream>"));
+  verifyFormat("\xef\xbb\xbf");
+  verifyFormat("\xef\xbb\xbf#include <iostream>");
+  verifyFormat("\xef\xbb\xbf\n#include <iostream>");
 }
 
 // FIXME: Encode Cyrillic and CJK characters below to appease MS compilers.
@@ -21127,8 +21107,7 @@ TEST_F(FormatTest, HandlesDoubleWidthCharsInMultiLineStrings) {
 }
 
 TEST_F(FormatTest, SplitsUTF8LineComments) {
-  EXPECT_EQ("// aaaaÄ\xc2\x8d",
-            format("// aaaaÄ\xc2\x8d", getLLVMStyleWithColumns(10)));
+  verifyFormat("// aaaaÄ\xc2\x8d", getLLVMStyleWithColumns(10));
   EXPECT_EQ("// Я из лесу\n"
             "// вышел; был\n"
             "// сильный\n"
@@ -21985,12 +21964,9 @@ TEST_F(FormatTest, FormatsLambdas) {
                "  return b;\n"
                "};",
                "auto c = []() { return b; };", MergeInline);
-  verifyFormat("function([]() { return b; })", "function([]() { return b; })",
-               MergeInline);
-  verifyFormat("function([]() { return b; }, a)",
-               "function([]() { return b; }, a)", MergeInline);
-  verifyFormat("function(a, []() { return b; })",
-               "function(a, []() { return b; })", MergeInline);
+  verifyFormat("function([]() { return b; })", MergeInline);
+  verifyFormat("function([]() { return b; }, a)", MergeInline);
+  verifyFormat("function(a, []() { return b; })", MergeInline);
 
   // Check option "BraceWrapping.BeforeLambdaBody" and 
diff erent state of
   // AllowShortLambdasOnASingleLine
@@ -22925,7 +22901,7 @@ TEST_F(FormatTest, HandleUnbalancedImplicitBracesAcrossPPBranches) {
                      "#if C\n"
                      "#else\n"
                      "#endif\n";
-  EXPECT_EQ(code, format(code));
+  verifyFormat(code);
 }
 
 TEST_F(FormatTest, HandleConflictMarkers) {
@@ -23143,12 +23119,12 @@ TEST_F(FormatTest, UTF8CharacterLiteralCpp03) {
 TEST_F(FormatTest, UTF8CharacterLiteralCpp11) {
   // u8'a' is a C++17 feature, utf8 literal character, LS_Cpp11 covers
   // all modes, including C++11, C++14 and C++17
-  EXPECT_EQ("auto c = u8'a';", format("auto c = u8'a';"));
+  verifyFormat("auto c = u8'a';");
 }
 
 TEST_F(FormatTest, DoNotFormatLikelyXml) {
-  EXPECT_EQ("<!-- ;> -->", format("<!-- ;> -->", getGoogleStyle()));
-  EXPECT_EQ(" <!-- >; -->", format(" <!-- >; -->", getGoogleStyle()));
+  verifyFormat("<!-- ;> -->", getGoogleStyle());
+  verifyNoChange(" <!-- >; -->", getGoogleStyle());
 }
 
 TEST_F(FormatTest, StructuredBindings) {
@@ -23771,13 +23747,11 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) {
 
   // Don't use the helpers here, since 'mess up' will change the whitespace
   // and these are all whitespace sensitive by definition
-  EXPECT_EQ("FOO(String-ized&Messy+But(: :Still)=Intentional);",
-            format("FOO(String-ized&Messy+But(: :Still)=Intentional);", Style));
+  verifyFormat("FOO(String-ized&Messy+But(: :Still)=Intentional);", Style);
   EXPECT_EQ(
       "FOO(String-ized&Messy+But\\(: :Still)=Intentional);",
       format("FOO(String-ized&Messy+But\\(: :Still)=Intentional);", Style));
-  EXPECT_EQ("FOO(String-ized&Messy+But,: :Still=Intentional);",
-            format("FOO(String-ized&Messy+But,: :Still=Intentional);", Style));
+  verifyFormat("FOO(String-ized&Messy+But,: :Still=Intentional);", Style);
   EXPECT_EQ("FOO(String-ized&Messy+But,: :\n"
             "       Still=Intentional);",
             format("FOO(String-ized&Messy+But,: :\n"
@@ -23791,8 +23765,7 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) {
                    Style));
 
   Style.ColumnLimit = 21;
-  EXPECT_EQ("FOO(String-ized&Messy+But: :Still=Intentional);",
-            format("FOO(String-ized&Messy+But: :Still=Intentional);", Style));
+  verifyFormat("FOO(String-ized&Messy+But: :Still=Intentional);", Style);
 }
 
 TEST_F(FormatTest, VeryLongNamespaceCommentSplit) {
@@ -24914,7 +24887,7 @@ TEST_F(FormatTest, StatementAttributeLikeMacros) {
                      "  Q_EMIT signal(MyChar);\n"
                      "}";
 
-  EXPECT_EQ(Source, format(Source, Style));
+  verifyFormat(Source, Style);
 
   Style.AlignConsecutiveDeclarations.Enabled = true;
   EXPECT_EQ("void Foo::slot() {\n"
@@ -24925,7 +24898,7 @@ TEST_F(FormatTest, StatementAttributeLikeMacros) {
             format(Source, Style));
 
   Style.StatementAttributeLikeMacros.push_back("emit");
-  EXPECT_EQ(Source, format(Source, Style));
+  verifyFormat(Source, Style);
 
   Style.StatementAttributeLikeMacros = {};
   EXPECT_EQ("void Foo::slot() {\n"
@@ -25020,7 +24993,7 @@ TEST_F(FormatTest, LimitlessStringsAndComments) {
       "  // Small line comment\n"
       "  return String.size() > SmallString.size();\n"
       "}";
-  EXPECT_EQ(Code, format(Code, Style));
+  verifyNoChange(Code, Style);
 }
 
 TEST_F(FormatTest, FormatDecayCopy) {
@@ -25717,7 +25690,7 @@ TEST_F(FormatTest, BreakAfterAttributes) {
                Code, Style);
 
   Style.BreakAfterAttributes = FormatStyle::ABS_Leave;
-  EXPECT_EQ(Code, format(Code, Style));
+  verifyNoChange(Code, Style);
 }
 
 TEST_F(FormatTest, InsertNewlineAtEOF) {
@@ -25733,7 +25706,7 @@ TEST_F(FormatTest, KeepEmptyLinesAtEOF) {
   Style.KeepEmptyLinesAtEOF = true;
 
   const StringRef Code{"int i;\n\n"};
-  verifyFormat(Code, Code, Style);
+  verifyNoChange(Code, Style);
   verifyFormat(Code, "int i;\n\n\n", Style);
 }
 

diff  --git a/clang/unittests/Format/FormatTestBase.h b/clang/unittests/Format/FormatTestBase.h
index 7d34bcc2d8351..40442d60aa330 100644
--- a/clang/unittests/Format/FormatTestBase.h
+++ b/clang/unittests/Format/FormatTestBase.h
@@ -120,6 +120,11 @@ class FormatTestBase : public ::testing::Test {
                   Style);
   }
 
+  void _verifyNoChange(const char *File, int Line, llvm::StringRef Code,
+                       const std::optional<FormatStyle> &Style = {}) {
+    _verifyFormat(File, Line, Code, Code, Style);
+  }
+
   /// \brief Verify that clang-format does not crash on the given input.
   void verifyNoCrash(llvm::StringRef Code,
                      const std::optional<FormatStyle> &Style = {}) {
@@ -135,6 +140,7 @@ class FormatTestBase : public ::testing::Test {
   _verifyIndependentOfContext(__FILE__, __LINE__, __VA_ARGS__)
 #define verifyIncompleteFormat(...)                                            \
   _verifyIncompleteFormat(__FILE__, __LINE__, __VA_ARGS__)
+#define verifyNoChange(...) _verifyNoChange(__FILE__, __LINE__, __VA_ARGS__)
 #define verifyFormat(...) _verifyFormat(__FILE__, __LINE__, __VA_ARGS__)
 #define verifyGoogleFormat(Code) verifyFormat(Code, getGoogleStyle())
 

diff  --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp
index 0cf7aaaa4bdb2..15c6767fc16ad 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -554,9 +554,8 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
             "          // one line",
             format("if (true) // A comment that doesn't fit on one line   ",
                    getLLVMStyleWithColumns(30)));
-  EXPECT_EQ("//    Don't_touch_leading_whitespace",
-            format("//    Don't_touch_leading_whitespace",
-                   getLLVMStyleWithColumns(20)));
+  verifyNoChange("//    Don't_touch_leading_whitespace",
+                 getLLVMStyleWithColumns(20));
   EXPECT_EQ("// Add leading\n"
             "// whitespace",
             format("//Add leading whitespace", getLLVMStyleWithColumns(20)));
@@ -571,7 +570,7 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
             "// limit",
             format("//Even if it makes the line exceed the column limit",
                    getLLVMStyleWithColumns(51)));
-  EXPECT_EQ("//--But not here", format("//--But not here", getLLVMStyle()));
+  verifyFormat("//--But not here", getLLVMStyle());
   EXPECT_EQ("/// line 1\n"
             "// add leading whitespace",
             format("/// line 1\n"
@@ -614,9 +613,8 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
                    "    int bbbbbbbbbb, // xxxxxxx yyyyyyyyyy\n"
                    "    int c, int d, int e) {}",
                    getLLVMStyleWithColumns(40)));
-  EXPECT_EQ("//\t aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-            format("//\t aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-                   getLLVMStyleWithColumns(20)));
+  verifyFormat("//\t aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+               getLLVMStyleWithColumns(20));
   EXPECT_EQ(
       "#define XXX // a b c d\n"
       "            // e f g h",
@@ -1065,7 +1063,7 @@ TEST_F(FormatTestComments, KeepsLevelOfCommentBeforePPDirective) {
                        "  #define KV(value) #value, value\n"
                        "  // clang-format on\n"
                        "}");
-  EXPECT_EQ(Code, format(Code));
+  verifyNoChange(Code);
 }
 
 TEST_F(FormatTestComments, SplitsLongLinesInComments) {
@@ -1228,9 +1226,8 @@ TEST_F(FormatTestComments, SplitsLongLinesInComments) {
 
   // This reproduces a crashing bug where both adaptStartOfLine and
   // getCommentSplit were trying to wrap after the "/**".
-  EXPECT_EQ("/** multilineblockcommentwithnowrapopportunity */",
-            format("/** multilineblockcommentwithnowrapopportunity */",
-                   getLLVMStyleWithColumns(20)));
+  verifyFormat("/** multilineblockcommentwithnowrapopportunity */",
+               getLLVMStyleWithColumns(20));
 
   EXPECT_EQ("/*\n"
             "\n"
@@ -1651,8 +1648,7 @@ TEST_F(FormatTestComments, ReflowsComments) {
                                         getLLVMStyleWithColumns(20)));
 
   // Don't shrink leading whitespace.
-  EXPECT_EQ("int i; ///           a",
-            format("int i; ///           a", getLLVMStyleWithColumns(20)));
+  verifyNoChange("int i; ///           a", getLLVMStyleWithColumns(20));
 
   // Shrink trailing whitespace if there is no postfix and reflow.
   EXPECT_EQ("// long long long\n"
@@ -2363,7 +2359,7 @@ TEST_F(FormatTestComments, BlockComments) {
             format("#define A\n"
                    "/* */someCall(parameter);",
                    getLLVMStyleWithColumns(15)));
-  EXPECT_EQ("/*\n**\n*/", format("/*\n**\n*/"));
+  verifyNoChange("/*\n**\n*/");
   EXPECT_EQ("/*\n"
             " *\n"
             " * aaaaaa\n"
@@ -3523,7 +3519,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
             format(NoTextInComment, Style));
 
   Style.SpacesInLineCommentPrefix.Minimum = 0;
-  EXPECT_EQ("//#comment", format("//#comment", Style));
+  verifyFormat("//#comment", Style);
   EXPECT_EQ("//\n"
             "\n"
             "void foo() { //\n"

diff  --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index ce81bd5d2f044..1df7859e715ba 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -116,12 +116,10 @@ TEST_F(FormatTestJS, JSDocComments) {
                    " */",
                    getGoogleJSStyleWithColumns(20)));
   // Don't break the first line of a short single line jsdoc comment.
-  EXPECT_EQ("/** jsdoc line 1 */",
-            format("/** jsdoc line 1 */", getGoogleJSStyleWithColumns(20)));
+  verifyFormat("/** jsdoc line 1 */", getGoogleJSStyleWithColumns(20));
   // Don't break the first line of a single line jsdoc comment if it just fits
   // the column limit.
-  EXPECT_EQ("/** jsdoc line 12 */",
-            format("/** jsdoc line 12 */", getGoogleJSStyleWithColumns(20)));
+  verifyFormat("/** jsdoc line 12 */", getGoogleJSStyleWithColumns(20));
   // Don't break after '/**' and before '*/' if there is no space between
   // '/**' and the content.
   EXPECT_EQ(
@@ -183,8 +181,7 @@ TEST_F(FormatTestJS, JSDocComments) {
                    getGoogleJSStyleWithColumns(20)));
 
   // Don't break the first line of a single line short jsdoc comment pragma.
-  EXPECT_EQ("/** @returns j */",
-            format("/** @returns j */", getGoogleJSStyleWithColumns(20)));
+  verifyFormat("/** @returns j */", getGoogleJSStyleWithColumns(20));
 
   // Break a single line long jsdoc comment pragma.
   EXPECT_EQ("/**\n"

diff  --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index 7b25a0bb4bdfd..51afe79859ec0 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -567,8 +567,7 @@ TEST_F(FormatTestJava, FormatsLambdas) {
 TEST_F(FormatTestJava, BreaksStringLiterals) {
   // FIXME: String literal breaking is currently disabled for Java and JS, as it
   // requires strings to be merged using "+" which we don't support.
-  EXPECT_EQ("\"some text other\";",
-            format("\"some text other\";", getStyleWithColumns(14)));
+  verifyFormat("\"some text other\";", getStyleWithColumns(14));
 }
 
 TEST_F(FormatTestJava, AlignsBlockComments) {

diff  --git a/clang/unittests/Format/QualifierFixerTest.cpp b/clang/unittests/Format/QualifierFixerTest.cpp
index 9760c80dcc619..d938308d68496 100755
--- a/clang/unittests/Format/QualifierFixerTest.cpp
+++ b/clang/unittests/Format/QualifierFixerTest.cpp
@@ -116,7 +116,7 @@ TEST_F(QualifierFixerTest, QualifiersCustomOrder) {
   Style.QualifierOrder = {"friend", "inline",   "constexpr", "static",
                           "const",  "volatile", "type"};
 
-  verifyFormat("const volatile int a;", "const volatile int a;", Style);
+  verifyFormat("const volatile int a;", Style);
   verifyFormat("const volatile int a;", "volatile const int a;", Style);
   verifyFormat("const volatile int a;", "int const volatile a;", Style);
   verifyFormat("const volatile int a;", "int volatile const a;", Style);
@@ -240,7 +240,7 @@ TEST_F(QualifierFixerTest, RightQualifier) {
   verifyFormat("int const *a;", "const int *a;", Style);
   verifyFormat("int const &a;", "const int &a;", Style);
   verifyFormat("foo(int const &a)", "foo(const int &a)", Style);
-  verifyFormat("unsigned char *a;", "unsigned char *a;", Style);
+  verifyFormat("unsigned char *a;", Style);
   verifyFormat("unsigned char const *a;", "const unsigned char *a;", Style);
   verifyFormat("vector<int, int const, int &, int const &> args1",
                "vector<int, const int, int &, const int &> args1", Style);
@@ -283,7 +283,7 @@ TEST_F(QualifierFixerTest, RightQualifier) {
                Style);
 
   verifyFormat("static int const bat;", "static const int bat;", Style);
-  verifyFormat("static int const bat;", "static int const bat;", Style);
+  verifyFormat("static int const bat;", Style);
 
   // static is not configured, unchanged on the left of the right hand
   // qualifiers.
@@ -303,7 +303,7 @@ TEST_F(QualifierFixerTest, RightQualifier) {
   verifyFormat("Foo inline static const;", "const Foo inline static;", Style);
   verifyFormat("Foo inline static const;", "Foo const inline static;", Style);
   verifyFormat("Foo inline static const;", "Foo inline const static;", Style);
-  verifyFormat("Foo inline static const;", "Foo inline static const;", Style);
+  verifyFormat("Foo inline static const;", Style);
 
   verifyFormat("Foo<T volatile>::Bar<Type const, 5> const volatile A::*;",
                "volatile const Foo<volatile T>::Bar<const Type, 5> A::*;",
@@ -311,11 +311,9 @@ TEST_F(QualifierFixerTest, RightQualifier) {
 
   verifyFormat("int const Foo<int>::bat = 0;", "const int Foo<int>::bat = 0;",
                Style);
-  verifyFormat("int const Foo<int>::bat = 0;", "int const Foo<int>::bat = 0;",
-               Style);
+  verifyFormat("int const Foo<int>::bat = 0;", Style);
   verifyFormat("void fn(Foo<T> const &i);", "void fn(const Foo<T> &i);", Style);
-  verifyFormat("int const Foo<int>::fn() {", "int const Foo<int>::fn() {",
-               Style);
+  verifyFormat("int const Foo<int>::fn() {", Style);
   verifyFormat("Foo<Foo<int>> const *p;", "const Foo<Foo<int>> *p;", Style);
   verifyFormat(
       "Foo<Foo<int>> const *p = const_cast<Foo<Foo<int>> const *>(&ffi);",
@@ -384,36 +382,29 @@ TEST_F(QualifierFixerTest, RightQualifier) {
                Style);
 
   // Don't move past C-style struct/class.
-  verifyFormat("void foo(const struct A a);", "void foo(const struct A a);",
-               Style);
-  verifyFormat("void foo(const class A a);", "void foo(const class A a);",
-               Style);
+  verifyFormat("void foo(const struct A a);", Style);
+  verifyFormat("void foo(const class A a);", Style);
 
   // Don't move past struct/class combined declaration and variable
   // definition.
-  verifyFormat("const struct {\n} var;", "const struct {\n} var;", Style);
-  verifyFormat("struct {\n} const var;", "struct {\n} const var;", Style);
-  verifyFormat("const class {\n} var;", "const class {\n} var;", Style);
-  verifyFormat("class {\n} const var;", "class {\n} const var;", Style);
+  verifyFormat("const struct {\n} var;", Style);
+  verifyFormat("struct {\n} const var;", Style);
+  verifyFormat("const class {\n} var;", Style);
+  verifyFormat("class {\n} const var;", Style);
 
   // Leave left qualifers unchanged for combined declaration and variable
   // definition.
-  verifyFormat("volatile const class {\n} var;",
-               "volatile const class {\n} var;", Style);
-  verifyFormat("const volatile class {\n} var;",
-               "const volatile class {\n} var;", Style);
+  verifyFormat("volatile const class {\n} var;", Style);
+  verifyFormat("const volatile class {\n} var;", Style);
   // Also do no sorting with respect to not-configured tokens.
-  verifyFormat("const static volatile class {\n} var;",
-               "const static volatile class {\n} var;", Style);
+  verifyFormat("const static volatile class {\n} var;", Style);
   // Sort right qualifiers for combined declaration and variable definition.
-  verifyFormat("class {\n} const volatile var;",
-               "class {\n} const volatile var;", Style);
+  verifyFormat("class {\n} const volatile var;", Style);
   verifyFormat("class {\n} const volatile var;",
                "class {\n} volatile const var;", Style);
   // Static keyword is not configured, should end up on the left of the right
   // side.
-  verifyFormat("class {\n} static const volatile var;",
-               "class {\n} static const volatile var;", Style);
+  verifyFormat("class {\n} static const volatile var;", Style);
   verifyFormat("class {\n} static const volatile var;",
                "class {\n} volatile static const var;", Style);
 
@@ -442,9 +433,9 @@ TEST_F(QualifierFixerTest, RightQualifier) {
                Style);
 
   // Don't move past decltype, typeof, or _Atomic.
-  verifyFormat("const decltype(foo)", "const decltype(foo)", Style);
-  verifyFormat("const typeof(foo)", "const typeof(foo)", Style);
-  verifyFormat("const _Atomic(foo)", "const _Atomic(foo)", Style);
+  verifyFormat("const decltype(foo)", Style);
+  verifyFormat("const typeof(foo)", Style);
+  verifyFormat("const _Atomic(foo)", Style);
 
   // Comments
   const int ColumnLimit = Style.ColumnLimit;
@@ -510,22 +501,19 @@ TEST_F(QualifierFixerTest, RightQualifier) {
                "const unsigned /*c*/ long /*c*/ long a;", Style);
 
   // Not changed
-  verifyFormat("foo() /*c*/ const", "foo() /*c*/ const", Style);
-  verifyFormat("const /*c*/ struct a;", "const /*c*/ struct a;", Style);
-  verifyFormat("const /*c*/ class a;", "const /*c*/ class a;", Style);
-  verifyFormat("const /*c*/ decltype(v) a;", "const /*c*/ decltype(v) a;",
-               Style);
-  verifyFormat("const /*c*/ typeof(v) a;", "const /*c*/ typeof(v) a;", Style);
-  verifyFormat("const /*c*/ _Atomic(v) a;", "const /*c*/ _Atomic(v) a;", Style);
-  verifyFormat("const decltype /*c*/ (v) a;", "const decltype /*c*/ (v) a;",
-               Style);
-  verifyFormat("const /*c*/ class {\n} volatile /*c*/ foo = {};",
-               "const /*c*/ class {\n} volatile /*c*/ foo = {};", Style);
+  verifyFormat("foo() /*c*/ const", Style);
+  verifyFormat("const /*c*/ struct a;", Style);
+  verifyFormat("const /*c*/ class a;", Style);
+  verifyFormat("const /*c*/ decltype(v) a;", Style);
+  verifyFormat("const /*c*/ typeof(v) a;", Style);
+  verifyFormat("const /*c*/ _Atomic(v) a;", Style);
+  verifyFormat("const decltype /*c*/ (v) a;", Style);
+  verifyFormat("const /*c*/ class {\n} volatile /*c*/ foo = {};", Style);
 
   Style.ColumnLimit = ColumnLimit;
 
   // Don't adjust macros
-  verifyFormat("const INTPTR a;", "const INTPTR a;", Style);
+  verifyFormat("const INTPTR a;", Style);
 
   // Pointers to members
   verifyFormat("int S::*a;", Style);
@@ -583,18 +571,17 @@ TEST_F(QualifierFixerTest, LeftQualifier) {
   verifyFormat("const int *a;", "int const *a;", Style);
   verifyFormat("const int &a;", "int const &a;", Style);
   verifyFormat("foo(const int &a)", "foo(int const &a)", Style);
-  verifyFormat("unsigned char *a;", "unsigned char *a;", Style);
+  verifyFormat("unsigned char *a;", Style);
   verifyFormat("const unsigned int &get_nu() const",
                "unsigned int const &get_nu() const", Style);
 
   verifyFormat("const volatile int;", "volatile const int;", Style);
-  verifyFormat("const volatile int;", "const volatile int;", Style);
+  verifyFormat("const volatile int;", Style);
   verifyFormat("const volatile int;", "const int volatile;", Style);
 
   verifyFormat("const volatile int *restrict;", "volatile const int *restrict;",
                Style);
-  verifyFormat("const volatile int *restrict;", "const volatile int *restrict;",
-               Style);
+  verifyFormat("const volatile int *restrict;", Style);
   verifyFormat("const volatile int *restrict;", "const int volatile *restrict;",
                Style);
 
@@ -626,18 +613,16 @@ TEST_F(QualifierFixerTest, LeftQualifier) {
       "template <typename Func> explicit Action(Action<Func> const &action);",
       Style);
 
-  verifyFormat("static const int bat;", "static const int bat;", Style);
+  verifyFormat("static const int bat;", Style);
   verifyFormat("static const int bat;", "static int const bat;", Style);
 
-  verifyFormat("static const int Foo<int>::bat = 0;",
-               "static const int Foo<int>::bat = 0;", Style);
+  verifyFormat("static const int Foo<int>::bat = 0;", Style);
   verifyFormat("static const int Foo<int>::bat = 0;",
                "static int const Foo<int>::bat = 0;", Style);
 
   verifyFormat("void fn(const Foo<T> &i);");
 
-  verifyFormat("const int Foo<int>::bat = 0;", "const int Foo<int>::bat = 0;",
-               Style);
+  verifyFormat("const int Foo<int>::bat = 0;", Style);
   verifyFormat("const int Foo<int>::bat = 0;", "int const Foo<int>::bat = 0;",
                Style);
   verifyFormat("void fn(const Foo<T> &i);", "void fn( Foo<T> const &i);",
@@ -685,10 +670,10 @@ TEST_F(QualifierFixerTest, LeftQualifier) {
   verifyFormat("const long long unsigned a;", "long const long unsigned a;",
                Style);
 
-  verifyFormat("const std::Foo", "const std::Foo", Style);
-  verifyFormat("const std::Foo<>", "const std::Foo<>", Style);
+  verifyFormat("const std::Foo", Style);
+  verifyFormat("const std::Foo<>", Style);
   verifyFormat("const std::Foo < int", "const std::Foo<int", Style);
-  verifyFormat("const std::Foo<int>", "const std::Foo<int>", Style);
+  verifyFormat("const std::Foo<int>", Style);
 
   // Multiple template parameters.
   verifyFormat("Bar<const std::Foo, 32>;", "Bar<std::Foo const, 32>;", Style);
@@ -701,30 +686,25 @@ TEST_F(QualifierFixerTest, LeftQualifier) {
                Style);
 
   // Don't move past C-style struct/class.
-  verifyFormat("void foo(struct A const a);", "void foo(struct A const a);",
-               Style);
-  verifyFormat("void foo(class A const a);", "void foo(class A const a);",
-               Style);
+  verifyFormat("void foo(struct A const a);", Style);
+  verifyFormat("void foo(class A const a);", Style);
 
   // Don't move past struct/class combined declaration and variable
   // definition.
-  verifyFormat("const struct {\n} var;", "const struct {\n} var;", Style);
-  verifyFormat("struct {\n} const var;", "struct {\n} const var;", Style);
-  verifyFormat("const class {\n} var;", "const class {\n} var;", Style);
-  verifyFormat("class {\n} const var;", "class {\n} const var;", Style);
+  verifyFormat("const struct {\n} var;", Style);
+  verifyFormat("struct {\n} const var;", Style);
+  verifyFormat("const class {\n} var;", Style);
+  verifyFormat("class {\n} const var;", Style);
 
   // Sort left qualifiers for struct/class combined declaration and variable
   // definition.
-  verifyFormat("const volatile class {\n} var;",
-               "const volatile class {\n} var;", Style);
+  verifyFormat("const volatile class {\n} var;", Style);
   verifyFormat("const volatile class {\n} var;",
                "volatile const class {\n} var;", Style);
   // Leave right qualifers unchanged for struct/class combined declaration and
   // variable definition.
-  verifyFormat("class {\n} const volatile var;",
-               "class {\n} const volatile var;", Style);
-  verifyFormat("class {\n} volatile const var;",
-               "class {\n} volatile const var;", Style);
+  verifyFormat("class {\n} const volatile var;", Style);
+  verifyFormat("class {\n} volatile const var;", Style);
 
   verifyFormat("foo<const Bar<Baz<T>>>();", "foo<Bar<Baz<T>> const>();", Style);
   verifyFormat("foo<const Bar<Baz<T>>>();", "foo<Bar<Baz<T> > const>();",
@@ -735,9 +715,9 @@ TEST_F(QualifierFixerTest, LeftQualifier) {
                Style);
 
   // Don't move past decltype, typeof, or _Atomic.
-  verifyFormat("decltype(foo) const", "decltype(foo) const", Style);
-  verifyFormat("typeof(foo) const", "typeof(foo) const", Style);
-  verifyFormat("_Atomic(foo) const", "_Atomic(foo) const", Style);
+  verifyFormat("decltype(foo) const", Style);
+  verifyFormat("typeof(foo) const", Style);
+  verifyFormat("_Atomic(foo) const", Style);
 
   // ::template for dependent names
   verifyFormat("const volatile ::template Foo<T> var;",
@@ -820,22 +800,19 @@ TEST_F(QualifierFixerTest, LeftQualifier) {
                "unsigned /*c*/ long /*c*/ long const a;", Style);
 
   // Not changed
-  verifyFormat("foo() /*c*/ const", "foo() /*c*/ const", Style);
-  verifyFormat("struct /*c*/ const a;", "struct /*c*/ const a;", Style);
-  verifyFormat("class /*c*/ const a;", "class /*c*/ const a;", Style);
-  verifyFormat("decltype(v) /*c*/ const a;", "decltype(v) /*c*/ const a;",
-               Style);
-  verifyFormat("typeof(v) /*c*/ const a;", "typeof(v) /*c*/ const a;", Style);
-  verifyFormat("_Atomic(v) /*c*/ const a;", "_Atomic(v) /*c*/ const a;", Style);
-  verifyFormat("decltype /*c*/ (v) const a;", "decltype /*c*/ (v) const a;",
-               Style);
-  verifyFormat("const /*c*/ class {\n} /*c*/ volatile /*c*/ foo = {};",
-               "const /*c*/ class {\n} /*c*/ volatile /*c*/ foo = {};", Style);
+  verifyFormat("foo() /*c*/ const", Style);
+  verifyFormat("struct /*c*/ const a;", Style);
+  verifyFormat("class /*c*/ const a;", Style);
+  verifyFormat("decltype(v) /*c*/ const a;", Style);
+  verifyFormat("typeof(v) /*c*/ const a;", Style);
+  verifyFormat("_Atomic(v) /*c*/ const a;", Style);
+  verifyFormat("decltype /*c*/ (v) const a;", Style);
+  verifyFormat("const /*c*/ class {\n} /*c*/ volatile /*c*/ foo = {};", Style);
 
   Style.ColumnLimit = ColumnLimit;
 
   // Don't adjust macros
-  verifyFormat("INTPTR const a;", "INTPTR const a;", Style);
+  verifyFormat("INTPTR const a;", Style);
 
   // Pointers to members
   verifyFormat("int S::*a;", Style);
@@ -856,13 +833,13 @@ TEST_F(QualifierFixerTest, ConstVolatileQualifiersOrder) {
   // The Default
   EXPECT_EQ(Style.QualifierOrder.size(), (size_t)5);
 
-  verifyFormat("const volatile int a;", "const volatile int a;", Style);
+  verifyFormat("const volatile int a;", Style);
   verifyFormat("const volatile int a;", "volatile const int a;", Style);
   verifyFormat("const volatile int a;", "int const volatile a;", Style);
   verifyFormat("const volatile int a;", "int volatile const a;", Style);
   verifyFormat("const volatile int a;", "const int volatile a;", Style);
 
-  verifyFormat("const volatile Foo a;", "const volatile Foo a;", Style);
+  verifyFormat("const volatile Foo a;", Style);
   verifyFormat("const volatile Foo a;", "volatile const Foo a;", Style);
   verifyFormat("const volatile Foo a;", "Foo const volatile a;", Style);
   verifyFormat("const volatile Foo a;", "Foo volatile const a;", Style);
@@ -873,13 +850,13 @@ TEST_F(QualifierFixerTest, ConstVolatileQualifiersOrder) {
 
   verifyFormat("int const volatile a;", "const volatile int a;", Style);
   verifyFormat("int const volatile a;", "volatile const int a;", Style);
-  verifyFormat("int const volatile a;", "int const volatile a;", Style);
+  verifyFormat("int const volatile a;", Style);
   verifyFormat("int const volatile a;", "int volatile const a;", Style);
   verifyFormat("int const volatile a;", "const int volatile a;", Style);
 
   verifyFormat("Foo const volatile a;", "const volatile Foo a;", Style);
   verifyFormat("Foo const volatile a;", "volatile const Foo a;", Style);
-  verifyFormat("Foo const volatile a;", "Foo const volatile a;", Style);
+  verifyFormat("Foo const volatile a;", Style);
   verifyFormat("Foo const volatile a;", "Foo volatile const a;", Style);
   verifyFormat("Foo const volatile a;", "const Foo volatile a;", Style);
 
@@ -887,13 +864,13 @@ TEST_F(QualifierFixerTest, ConstVolatileQualifiersOrder) {
   Style.QualifierOrder = {"volatile", "const", "type"};
 
   verifyFormat("volatile const int a;", "const volatile int a;", Style);
-  verifyFormat("volatile const int a;", "volatile const int a;", Style);
+  verifyFormat("volatile const int a;", Style);
   verifyFormat("volatile const int a;", "int const volatile a;", Style);
   verifyFormat("volatile const int a;", "int volatile const a;", Style);
   verifyFormat("volatile const int a;", "const int volatile a;", Style);
 
   verifyFormat("volatile const Foo a;", "const volatile Foo a;", Style);
-  verifyFormat("volatile const Foo a;", "volatile const Foo a;", Style);
+  verifyFormat("volatile const Foo a;", Style);
   verifyFormat("volatile const Foo a;", "Foo const volatile a;", Style);
   verifyFormat("volatile const Foo a;", "Foo volatile const a;", Style);
   verifyFormat("volatile const Foo a;", "const Foo volatile a;", Style);
@@ -904,13 +881,13 @@ TEST_F(QualifierFixerTest, ConstVolatileQualifiersOrder) {
   verifyFormat("int volatile const a;", "const volatile int a;", Style);
   verifyFormat("int volatile const a;", "volatile const int a;", Style);
   verifyFormat("int volatile const a;", "int const volatile a;", Style);
-  verifyFormat("int volatile const a;", "int volatile const a;", Style);
+  verifyFormat("int volatile const a;", Style);
   verifyFormat("int volatile const a;", "const int volatile a;", Style);
 
   verifyFormat("Foo volatile const a;", "const volatile Foo a;", Style);
   verifyFormat("Foo volatile const a;", "volatile const Foo a;", Style);
   verifyFormat("Foo volatile const a;", "Foo const volatile a;", Style);
-  verifyFormat("Foo volatile const a;", "Foo volatile const a;", Style);
+  verifyFormat("Foo volatile const a;", Style);
   verifyFormat("Foo volatile const a;", "const Foo volatile a;", Style);
 
   Style.QualifierAlignment = FormatStyle::QAS_Custom;
@@ -919,13 +896,13 @@ TEST_F(QualifierFixerTest, ConstVolatileQualifiersOrder) {
   verifyFormat("int volatile const a;", "const volatile int a;", Style);
   verifyFormat("int volatile const a;", "volatile const int a;", Style);
   verifyFormat("int volatile const a;", "int const volatile a;", Style);
-  verifyFormat("int volatile const a;", "int volatile const a;", Style);
+  verifyFormat("int volatile const a;", Style);
   verifyFormat("int volatile const a;", "const int volatile a;", Style);
 
   verifyFormat("Foo volatile const a;", "const volatile Foo a;", Style);
   verifyFormat("Foo volatile const a;", "volatile const Foo a;", Style);
   verifyFormat("Foo volatile const a;", "Foo const volatile a;", Style);
-  verifyFormat("Foo volatile const a;", "Foo volatile const a;", Style);
+  verifyFormat("Foo volatile const a;", Style);
   verifyFormat("Foo volatile const a;", "const Foo volatile a;", Style);
 }
 
@@ -1155,8 +1132,7 @@ TEST_F(QualifierFixerTest, DontPushQualifierThroughNonSpecifiedTypes) {
   Style.QualifierOrder = {"static", "const", "type"};
 
   verifyFormat("inline static const int a;", Style);
-  verifyFormat("static inline const int a;", "static inline const int a;",
-               Style);
+  verifyFormat("static inline const int a;", Style);
 
   verifyFormat("static const int a;", "const static int a;", Style);
 
@@ -1176,11 +1152,11 @@ TEST_F(QualifierFixerTest, DontPushQualifierThroughNonSpecifiedTypes) {
                Style);
 
   verifyFormat("inline static const Foo;", "inline static Foo const;", Style);
-  verifyFormat("inline static const Foo;", "inline static const Foo;", Style);
+  verifyFormat("inline static const Foo;", Style);
 
   // Don't move qualifiers to the right for aestethics only.
-  verifyFormat("inline const static Foo;", "inline const static Foo;", Style);
-  verifyFormat("const inline static Foo;", "const inline static Foo;", Style);
+  verifyFormat("inline const static Foo;", Style);
+  verifyFormat("const inline static Foo;", Style);
 }
 
 TEST_F(QualifierFixerTest, UnsignedQualifier) {


        


More information about the cfe-commits mailing list