@@ -24954,105 +24954,6 @@ TEST_F(FormatTest, DisableRegions) {
2495424954 "// clang-format on");
2495524955}
2495624956
24957- TEST_F(FormatTest, OneLineFormatOffRegex) {
24958- auto Style = getLLVMStyle();
24959- Style.OneLineFormatOffRegex = "// format off$";
24960-
24961- verifyFormat(" // format off\n"
24962- " int i ;\n"
24963- "int j;",
24964- " // format off\n"
24965- " int i ;\n"
24966- " int j ;",
24967- Style);
24968- verifyFormat("// format off?\n"
24969- "int i;",
24970- " // format off?\n"
24971- " int i ;",
24972- Style);
24973- verifyFormat("f(\"// format off\");", " f(\"// format off\") ;", Style);
24974-
24975- verifyFormat("int i;\n"
24976- " // format off\n"
24977- " int j ;\n"
24978- "int k;",
24979- " int i ;\n"
24980- " // format off\n"
24981- " int j ;\n"
24982- " int k ;",
24983- Style);
24984-
24985- verifyFormat(" // format off\n"
24986- "\n"
24987- "int i;",
24988- " // format off\n"
24989- " \n"
24990- " int i ;",
24991- Style);
24992-
24993- verifyFormat("int i;\n"
24994- " int j ; // format off\n"
24995- "int k;",
24996- " int i ;\n"
24997- " int j ; // format off\n"
24998- " int k ;",
24999- Style);
25000-
25001- verifyFormat("// clang-format off\n"
25002- " int i ;\n"
25003- " int j ; // format off\n"
25004- " int k ;\n"
25005- "// clang-format on\n"
25006- "f();",
25007- " // clang-format off\n"
25008- " int i ;\n"
25009- " int j ; // format off\n"
25010- " int k ;\n"
25011- " // clang-format on\n"
25012- " f() ;",
25013- Style);
25014-
25015- Style.OneLineFormatOffRegex = "^/\\* format off \\*/";
25016- verifyFormat("int i;\n"
25017- " /* format off */ int j ;\n"
25018- "int k;",
25019- " int i ;\n"
25020- " /* format off */ int j ;\n"
25021- " int k ;",
25022- Style);
25023- verifyFormat("f(\"/* format off */\");", " f(\"/* format off */\") ;", Style);
25024-
25025- Style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
25026- verifyFormat("#define A \\\n"
25027- " do { \\\n"
25028- " /* format off */\\\n"
25029- " f() ; \\\n"
25030- " g(); \\\n"
25031- " } while (0)",
25032- "# define A\\\n"
25033- " do{ \\\n"
25034- " /* format off */\\\n"
25035- " f() ; \\\n"
25036- " g() ;\\\n"
25037- " } while (0 )",
25038- Style);
25039-
25040- Style.ColumnLimit = 50;
25041- Style.OneLineFormatOffRegex = "^LogErrorPrint$";
25042- verifyFormat(" myproject::LogErrorPrint(logger, \"Don't split me!\");\n"
25043- "myproject::MyLogErrorPrinter(myLogger,\n"
25044- " \"Split me!\");",
25045- " myproject::LogErrorPrint(logger, \"Don't split me!\");\n"
25046- " myproject::MyLogErrorPrinter(myLogger, \"Split me!\");",
25047- Style);
25048-
25049- Style.OneLineFormatOffRegex = "//(< clang-format off| NO_TRANSLATION)$";
25050- verifyNoChange(
25051- " int i ; //< clang-format off\n"
25052- " msg = sprintf(\"Long string with placeholders.\"); // NO_TRANSLATION",
25053- Style);
25054- }
25055-
2505624957TEST_F(FormatTest, DoNotCrashOnInvalidInput) {
2505724958 format("? ) =");
2505824959 verifyNoCrash("#define a\\\n /**/}");
0 commit comments