=?utf-8?q?Björn_Schäpers?= <[email protected]>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>


================
@@ -4218,485 +4217,277 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
                        "void f() {//Hello World\n"
                        "}";
 
-  EXPECT_EQ("// Lorem ipsum dolor\n"
-            "// sit amet\n"
-            "\n"
-            "//  Lorem   ipsum\n"
-            "//  dolor   sit amet\n"
-            "\n"
-            "void f() { // Hello\n"
-            "           // World\n"
-            "}",
-            format(WrapCode, Style));
+  verifyFormat("// Lorem ipsum dolor\n"
+               "// sit amet\n"
+               "\n"
+               "//  Lorem   ipsum\n"
+               "//  dolor   sit amet\n"
+               "\n"
+               "void f() { // Hello\n"
+               "           // World\n"
+               "}",
+               WrapCode, Style);
 
   Style.SpacesInLineCommentPrefix = {0, 0};
-  EXPECT_EQ("//Lorem ipsum dolor\n"
-            "//sit amet\n"
-            "\n"
-            "//Lorem   ipsum\n"
-            "//dolor   sit   amet\n"
-            "\n"
-            "void f() { //Hello\n"
-            "           //World\n"
-            "}",
-            format(WrapCode, Style));
+  verifyFormat("//Lorem ipsum dolor\n"
+               "//sit amet\n"
+               "\n"
+               "//Lorem   ipsum\n"
+               "//dolor   sit   amet\n"
+               "\n"
+               "void f() { //Hello\n"
+               "           //World\n"
+               "}",
+               WrapCode, Style);
 
   Style.SpacesInLineCommentPrefix = {1, 1};
-  EXPECT_EQ("// Lorem ipsum dolor\n"
-            "// sit amet\n"
-            "\n"
-            "// Lorem   ipsum\n"
-            "// dolor   sit amet\n"
-            "\n"
-            "void f() { // Hello\n"
-            "           // World\n"
-            "}",
-            format(WrapCode, Style));
-  EXPECT_EQ("// x\n"
-            "// y",
-            format("//   x\n"
-                   "// y",
-                   Style));
-  EXPECT_EQ(
+  verifyFormat("// Lorem ipsum dolor\n"
+               "// sit amet\n"
+               "\n"
+               "// Lorem   ipsum\n"
+               "// dolor   sit amet\n"
+               "\n"
+               "void f() { // Hello\n"
+               "           // World\n"
+               "}",
+               WrapCode, Style);
+  verifyFormat("// x\n"
+               "// y",
+               "//   x\n"
+               "// y",
+               Style);
+  verifyFormat(
       "// loooooooooooooooooooooooooooooong\n"
       "// commentcomments\n"
       "// normal comments",
-      format("//            loooooooooooooooooooooooooooooong 
commentcomments\n"
-             "// normal comments",
-             Style));
+      "//            loooooooooooooooooooooooooooooong commentcomments\n"
+      "// normal comments",
+      Style);
 
   Style.SpacesInLineCommentPrefix = {3, 3};
-  EXPECT_EQ("//   Lorem ipsum\n"
-            "//   dolor sit amet\n"
-            "\n"
-            "//   Lorem   ipsum\n"
-            "//   dolor   sit\n"
-            "//   amet\n"
-            "\n"
-            "void f() { //   Hello\n"
-            "           //   World\n"
-            "}",
-            format(WrapCode, Style));
+  verifyFormat("//   Lorem ipsum\n"
+               "//   dolor sit amet\n"
+               "\n"
+               "//   Lorem   ipsum\n"
+               "//   dolor   sit\n"
+               "//   amet\n"
+               "\n"
+               "void f() { //   Hello\n"
+               "           //   World\n"
+               "}",
+               WrapCode, Style);
 
   Style = getLLVMStyleWithColumns(20);
-  StringRef LotsOfSpaces = "//                      This are more spaces "
-                           "than the ColumnLimit, what now?\n"
-                           "\n"
-                           "//   Comment\n"
-                           "\n"
-                           "// This is a text to split in multiple "
-                           "lines, please. Thank you very much!\n"
-                           "\n"
-                           "// A comment with\n"
-                           "//   some indentation that has to be split.\n"
-                           "// And now without";
-  EXPECT_EQ("//                      This are more spaces "
-            "than the ColumnLimit, what now?\n"
-            "\n"
-            "//   Comment\n"
-            "\n"
-            "// This is a text to\n"
-            "// split in multiple\n"
-            "// lines, please.\n"
-            "// Thank you very\n"
-            "// much!\n"
-            "\n"
-            "// A comment with\n"
-            "//   some\n"
-            "//   indentation\n"
-            "//   that has to be\n"
-            "//   split.\n"
-            "// And now without",
-            format(LotsOfSpaces, Style));
+  constexpr StringRef LotsOfSpaces =
+      "//                      This are more spaces "
+      "than the ColumnLimit, what now?\n"
+      "\n"
+      "//   Comment\n"
+      "\n"
+      "// This is a text to split in multiple "
+      "lines, please. Thank you very much!\n"
+      "\n"
+      "// A comment with\n"
+      "//   some indentation that has to be split.\n"
+      "// And now without";
+  verifyFormat("//                      This are more spaces "
+               "than the ColumnLimit, what now?\n"
+               "\n"
+               "//   Comment\n"
+               "\n"
+               "// This is a text to\n"
+               "// split in multiple\n"
+               "// lines, please.\n"
+               "// Thank you very\n"
+               "// much!\n"
+               "\n"
+               "// A comment with\n"
+               "//   some\n"
+               "//   indentation\n"
+               "//   that has to be\n"
+               "//   split.\n"
+               "// And now without",
+               LotsOfSpaces, Style);
 
   Style.SpacesInLineCommentPrefix = {0, 0};
-  EXPECT_EQ("//This are more\n"
-            "//spaces than the\n"
-            "//ColumnLimit, what\n"
-            "//now?\n"
-            "\n"
-            "//Comment\n"
-            "\n"
-            "//This is a text to\n"
-            "//split in multiple\n"
-            "//lines, please.\n"
-            "//Thank you very\n"
-            "//much!\n"
-            "\n"
-            "//A comment with\n"
-            "//  some indentation\n"
-            "//  that has to be\n"
-            "//  split.\n"
-            "//And now without",
-            format(LotsOfSpaces, Style));
+  verifyFormat("//This are more\n"
+               "//spaces than the\n"
+               "//ColumnLimit, what\n"
+               "//now?\n"
+               "\n"
+               "//Comment\n"
+               "\n"
+               "//This is a text to\n"
+               "//split in multiple\n"
+               "//lines, please.\n"
+               "//Thank you very\n"
+               "//much!\n"
+               "\n"
+               "//A comment with\n"
+               "//  some indentation\n"
+               "//  that has to be\n"
+               "//  split.\n"
+               "//And now without",
+               LotsOfSpaces, Style);
 
   Style.SpacesInLineCommentPrefix = {3, 3};
-  EXPECT_EQ("//   This are more\n"
-            "//   spaces than the\n"
-            "//   ColumnLimit,\n"
-            "//   what now?\n"
-            "\n"
-            "//   Comment\n"
-            "\n"
-            "//   This is a text\n"
-            "//   to split in\n"
-            "//   multiple lines,\n"
-            "//   please. Thank\n"
-            "//   you very much!\n"
-            "\n"
-            "//   A comment with\n"
-            "//     some\n"
-            "//     indentation\n"
-            "//     that has to\n"
-            "//     be split.\n"
-            "//   And now without",
-            format(LotsOfSpaces, Style));
+  verifyFormat("//   This are more\n"
+               "//   spaces than the\n"
+               "//   ColumnLimit,\n"
+               "//   what now?\n"
+               "\n"
+               "//   Comment\n"
+               "\n"
+               "//   This is a text\n"
+               "//   to split in\n"
+               "//   multiple lines,\n"
+               "//   please. Thank\n"
+               "//   you very much!\n"
+               "\n"
+               "//   A comment with\n"
+               "//     some\n"
+               "//     indentation\n"
+               "//     that has to\n"
+               "//     be split.\n"
+               "//   And now without",
+               LotsOfSpaces, Style);
 
   Style.SpacesInLineCommentPrefix = {30, -1u};
-  EXPECT_EQ("//                              This are more spaces than the "
-            "ColumnLimit, what now?\n"
-            "\n"
-            "//                              Comment\n"
-            "\n"
-            "//                              This is a text to split in "
-            "multiple lines, please. Thank you very much!\n"
-            "\n"
-            "//                              A comment with\n"
-            "//                                some indentation that has to be 
"
-            "split.\n"
-            "//                              And now without",
-            format(LotsOfSpaces, Style));
+  verifyFormat(
+      "//                              This are more spaces than the "
+      "ColumnLimit, what now?\n"
+      "\n"
+      "//                              Comment\n"
+      "\n"
+      "//                              This is a text to split in "
+      "multiple lines, please. Thank you very much!\n"
+      "\n"
+      "//                              A comment with\n"
+      "//                                some indentation that has to be "
+      "split.\n"
+      "//                              And now without",
+      LotsOfSpaces, Style);
 
   Style.SpacesInLineCommentPrefix = {2, 4};
-  EXPECT_EQ("//  A Comment to be\n"
-            "//  moved\n"
-            "//   with indent\n"
-            "\n"
-            "//  A Comment to be\n"
-            "//  moved\n"
-            "//   with indent\n"
-            "\n"
-            "//  A Comment to be\n"
-            "//  moved\n"
-            "//   with indent\n"
-            "\n"
-            "//   A Comment to be\n"
-            "//   moved\n"
-            "//    with indent\n"
-            "\n"
-            "//    A Comment to\n"
-            "//    be moved\n"
-            "//     with indent\n"
-            "\n"
-            "//    A Comment to\n"
-            "//    be moved\n"
-            "//     with indent\n"
-            "\n"
-            "//    A Comment to\n"
-            "//    be moved\n"
-            "//     with indent",
-            format("//A Comment to be moved\n"
-                   "// with indent\n"
-                   "\n"
-                   "// A Comment to be moved\n"
-                   "//  with indent\n"
-                   "\n"
-                   "//  A Comment to be moved\n"
-                   "//   with indent\n"
-                   "\n"
-                   "//   A Comment to be moved\n"
-                   "//    with indent\n"
-                   "\n"
-                   "//    A Comment to be moved\n"
-                   "//     with indent\n"
-                   "\n"
-                   "//     A Comment to be moved\n"
-                   "//      with indent\n"
-                   "\n"
-                   "//      A Comment to be moved\n"
-                   "//       with indent",
-                   Style));
+  verifyFormat("//  A Comment to be\n"
+               "//  moved\n"
+               "//   with indent\n"
+               "\n"
+               "//  A Comment to be\n"
+               "//  moved\n"
+               "//   with indent\n"
+               "\n"
+               "//  A Comment to be\n"
+               "//  moved\n"
+               "//   with indent\n"
+               "\n"
+               "//   A Comment to be\n"
+               "//   moved\n"
+               "//    with indent\n"
+               "\n"
+               "//    A Comment to\n"
+               "//    be moved\n"
+               "//     with indent\n"
+               "\n"
+               "//    A Comment to\n"
+               "//    be moved\n"
+               "//     with indent\n"
+               "\n"
+               "//    A Comment to\n"
+               "//    be moved\n"
+               "//     with indent",
+               "//A Comment to be moved\n"
+               "// with indent\n"
+               "\n"
+               "// A Comment to be moved\n"
+               "//  with indent\n"
+               "\n"
+               "//  A Comment to be moved\n"
+               "//   with indent\n"
+               "\n"
+               "//   A Comment to be moved\n"
+               "//    with indent\n"
+               "\n"
+               "//    A Comment to be moved\n"
+               "//     with indent\n"
+               "\n"
+               "//     A Comment to be moved\n"
+               "//      with indent\n"
+               "\n"
+               "//      A Comment to be moved\n"
+               "//       with indent",
+               Style);
 
   Style.ColumnLimit = 30;
-  EXPECT_EQ("int i; //  A Comment to be\n"
-            "       //  moved\n"
-            "       //   with indent\n"
-            "\n"
-            "int i; //  A Comment to be\n"
-            "       //  moved\n"
-            "       //   with indent\n"
-            "\n"
-            "int i; //  A Comment to be\n"
-            "       //  moved\n"
-            "       //   with indent\n"
-            "\n"
-            "int i; //   A Comment to be\n"
-            "       //   moved\n"
-            "       //    with indent\n"
-            "\n"
-            "int i; //    A Comment to be\n"
-            "       //    moved\n"
-            "       //     with indent\n"
-            "\n"
-            "int i; //    A Comment to be\n"
-            "       //    moved\n"
-            "       //     with indent\n"
-            "\n"
-            "int i; //    A Comment to be\n"
-            "       //    moved\n"
-            "       //     with indent",
-            format("int i;//A Comment to be moved\n"
-                   "      // with indent\n"
-                   "\n"
-                   "int i;// A Comment to be moved\n"
-                   "      //  with indent\n"
-                   "\n"
-                   "int i;//  A Comment to be moved\n"
-                   "      //   with indent\n"
-                   "\n"
-                   "int i;//   A Comment to be moved\n"
-                   "      //    with indent\n"
-                   "\n"
-                   "int i;//    A Comment to be moved\n"
-                   "      //     with indent\n"
-                   "\n"
-                   "int i;//     A Comment to be moved\n"
-                   "      //      with indent\n"
-                   "\n"
-                   "int i;//      A Comment to be moved\n"
-                   "      //       with indent",
-                   Style));
+  verifyFormat("int i; //  A Comment to be\n"
+               "       //  moved\n"
+               "       //   with indent\n"
+               "\n"
+               "int i; //  A Comment to be\n"
+               "       //  moved\n"
+               "       //   with indent\n"
+               "\n"
+               "int i; //  A Comment to be\n"
+               "       //  moved\n"
+               "       //   with indent\n"
+               "\n"
+               "int i; //   A Comment to be\n"
+               "       //   moved\n"
+               "       //    with indent\n"
+               "\n"
+               "int i; //    A Comment to be\n"
+               "       //    moved\n"
+               "       //     with indent\n"
+               "\n"
+               "int i; //    A Comment to be\n"
+               "       //    moved\n"
+               "       //     with indent\n"
+               "\n"
+               "int i; //    A Comment to be\n"
+               "       //    moved\n"
+               "       //     with indent",
+               "int i;//A Comment to be moved\n"
+               "      // with indent\n"
+               "\n"
+               "int i;// A Comment to be moved\n"
+               "      //  with indent\n"
+               "\n"
+               "int i;//  A Comment to be moved\n"
+               "      //   with indent\n"
+               "\n"
+               "int i;//   A Comment to be moved\n"
+               "      //    with indent\n"
+               "\n"
+               "int i;//    A Comment to be moved\n"
+               "      //     with indent\n"
+               "\n"
+               "int i;//     A Comment to be moved\n"
+               "      //      with indent\n"
+               "\n"
+               "int i;//      A Comment to be moved\n"
+               "      //       with indent",
+               Style);
 
   Style = getLLVMStyleWithColumns(0);
-  EXPECT_EQ("// Free comment without space\n"
-            "\n"
-            "//   Free comment with 3 spaces\n"
-            "\n"
-            "/// Free Doxygen without space\n"
-            "\n"
-            "///   Free Doxygen with 3 spaces\n"
-            "\n"
-            "// 🐉 A nice dragon\n"
-            "\n"
-            "//\t abccba\n"
-            "\n"
-            "//\\t deffed\n"
-            "\n"
-            "//   🐉 Another nice dragon\n"
-            "\n"
-            "//   \t Three leading spaces following tab\n"
-            "\n"
-            "//   \\t Three leading spaces following backslash\n"
-            "\n"
-            "/// A Doxygen Comment with a nested list:\n"
-            "/// - Foo\n"
-            "/// - Bar\n"
-            "///   - Baz\n"
-            "///   - End\n"
-            "///     of the inner list\n"
-            "///   .\n"
-            "/// .\n"
-            "\n"
-            "namespace Foo {\n"
-            "bool bar(bool b) {\n"
-            "  bool ret1 = true; ///< Doxygenstyle without space\n"
-            "  bool ret2 = true; ///<   Doxygenstyle with 3 spaces\n"
-            "  if (b) {\n"
-            "    // Foo\n"
-            "\n"
-            "    //   In function comment\n"
-            "    ret2 = false;\n"
-            "  } // End of if\n"
-            "\n"
-            "  //  if (ret1) {\n"
-            "  //    return ret2;\n"
-            "  //  }\n"
-            "\n"
-            "  // if (ret1) {\n"
-            "  //   return ret2;\n"
-            "  // }\n"
-            "\n"
-            "  return ret1 && ret2;\n"
-            "}\n"
-            "} // namespace Foo\n"
-            "\n"
-            "namespace Bar {\n"
-            "int foo();\n"
-            "} //  namespace Bar\n"
-            "//@Nothing added because of the non ascii char\n"
-            "\n"
-            "//@      Nothing removed because of the non ascii char\n"
-            "\n"
-            "//  Comment to move to the left\n"
-            "// But not this?\n"
-            "//  @but this\n"
-            "\n"
-            "// Comment to move to the right\n"
-            "//@ this stays\n"
-            "\n"
-            "//} will not move\n"
-            "\n"
-            "// vv will only move\n"
-            "// } if the line above does",
-            format(Code, Style));
+  verifyFormat(Code2, Code, Style);
 
   Style.SpacesInLineCommentPrefix = {0, 0};
-  EXPECT_EQ("//Free comment without space\n"
-            "\n"
-            "//Free comment with 3 spaces\n"
-            "\n"
-            "///Free Doxygen without space\n"
-            "\n"
-            "///Free Doxygen with 3 spaces\n"
-            "\n"
-            "//🐉 A nice dragon\n"
-            "\n"
-            "//\t abccba\n"
-            "\n"
-            "//\\t deffed\n"
-            "\n"
-            "//🐉 Another nice dragon\n"
-            "\n"
-            "//\t Three leading spaces following tab\n"
-            "\n"
-            "//\\t Three leading spaces following backslash\n"
-            "\n"
-            "///A Doxygen Comment with a nested list:\n"
-            "///- Foo\n"
-            "///- Bar\n"
-            "///  - Baz\n" // Here we keep the relative indentation
-            "///  - End\n"
-            "///    of the inner list\n"
-            "///  .\n"
-            "///.\n"
-            "\n"
-            "namespace Foo {\n"
-            "bool bar(bool b) {\n"
-            "  bool ret1 = true; ///<Doxygenstyle without space\n"
-            "  bool ret2 = true; ///<Doxygenstyle with 3 spaces\n"
-            "  if (b) {\n"
-            "    //Foo\n"
-            "\n"
-            "    //In function comment\n"
-            "    ret2 = false;\n"
-            "  } //End of if\n"
-            "\n"
-            "  //if (ret1) {\n"
-            "  //  return ret2;\n"
-            "  //}\n"
-            "\n"
-            "  //if (ret1) {\n"
-            "  //  return ret2;\n"
-            "  //}\n"
-            "\n"
-            "  return ret1 && ret2;\n"
-            "}\n"
-            "} //namespace Foo\n"
-            "\n"
-            "namespace Bar {\n"
-            "int foo();\n"
-            "} //namespace Bar\n"
-            "//@Nothing added because of the non ascii char\n"
-            "\n"
-            "//@      Nothing removed because of the non ascii char\n"
-            "\n"
-            "//Comment to move to the left\n"
-            "//But not this?\n"
-            "//@but this\n"
-            "\n"
-            "//Comment to move to the right\n"
-            "//@ this stays\n"
-            "\n"
-            "//} will not move\n"
-            "\n"
-            "//vv will only move\n"
-            "//} if the line above does",
-            format(Code, Style));
+  verifyFormat(Code3, Code, Style);
 
   Style.SpacesInLineCommentPrefix = {2, -1u};
-  EXPECT_EQ("//  Free comment without space\n"
-            "\n"
-            "//   Free comment with 3 spaces\n"
-            "\n"
-            "///  Free Doxygen without space\n"
-            "\n"
-            "///   Free Doxygen with 3 spaces\n"
-            "\n"
-            "//  🐉 A nice dragon\n"
-            "\n"
-            "//\t abccba\n"
-            "\n"
-            "//\\t deffed\n"
-            "\n"
-            "//   🐉 Another nice dragon\n"
-            "\n"
-            "//   \t Three leading spaces following tab\n"
-            "\n"
-            "//   \\t Three leading spaces following backslash\n"
-            "\n"
-            "///  A Doxygen Comment with a nested list:\n"
-            "///  - Foo\n"
-            "///  - Bar\n"
-            "///    - Baz\n"
-            "///    - End\n"
-            "///      of the inner list\n"
-            "///    .\n"
-            "///  .\n"
-            "\n"
-            "namespace Foo {\n"
-            "bool bar(bool b) {\n"
-            "  bool ret1 = true; ///<  Doxygenstyle without space\n"
-            "  bool ret2 = true; ///<   Doxygenstyle with 3 spaces\n"
-            "  if (b) {\n"
-            "    //  Foo\n"
-            "\n"
-            "    //   In function comment\n"
-            "    ret2 = false;\n"
-            "  } //  End of if\n"
-            "\n"
-            "  //  if (ret1) {\n"
-            "  //    return ret2;\n"
-            "  //  }\n"
-            "\n"
-            "  //  if (ret1) {\n"
-            "  //    return ret2;\n"
-            "  //  }\n"
-            "\n"
-            "  return ret1 && ret2;\n"
-            "}\n"
-            "} //  namespace Foo\n"
-            "\n"
-            "namespace Bar {\n"
-            "int foo();\n"
-            "} //  namespace Bar\n"
-            "//@Nothing added because of the non ascii char\n"
-            "\n"
-            "//@      Nothing removed because of the non ascii char\n"
-            "\n"
-            "//  Comment to move to the left\n"
-            "//  But not this?\n"
-            "//  @but this\n"
-            "\n"
-            "//  Comment to move to the right\n"
-            "//@ this stays\n"
-            "\n"
-            "//} will not move\n"
-            "\n"
-            "//  vv will only move\n"
-            "//  } if the line above does",
-            format(Code, Style));
+  verifyFormat(Code4, Code, Style);
 }
 
 TEST_F(FormatTestComments, SplitCommentIntroducers) {
-  EXPECT_EQ(R"(//
+  verifyFormat(R"(//
 /\
 /
 )",
----------------
owenca wrote:

```suggestion
  verifyFormat("//\n"
               "/\\\n"
               "/\n",
```

https://github.com/llvm/llvm-project/pull/164310
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to