[clang] ece7e95 - [clang-format] NFC - clang-format the FormatTests
via cfe-commits
cfe-commits at lists.llvm.org
Sat May 2 07:42:42 PDT 2020
Author: mydeveloperday
Date: 2020-05-02T15:42:20+01:00
New Revision: ece7e95f02cdcdf9fa7c6fdfbf6db92e4cc0c87e
URL: https://github.com/llvm/llvm-project/commit/ece7e95f02cdcdf9fa7c6fdfbf6db92e4cc0c87e
DIFF: https://github.com/llvm/llvm-project/commit/ece7e95f02cdcdf9fa7c6fdfbf6db92e4cc0c87e.diff
LOG: [clang-format] NFC - clang-format the FormatTests
Summary:
Ensure the clang-format unit tests are themselves clang-formatted
Having areas of the llvm code which are clang-format clean, give us more areas to run new clang-format binaries on ensuring we haven't broken anything.
It seems to me we SHOULD have this clang-formatted at a minimum, otherwise how can we expect others to use clang-format if we "don't eat our own dogfood", also if the tests are dependent on the formatting of the code then that would also be bad!
Reviewed By: sammccall
Subscribers: cfe-commits
Tags: #clang, #clang-format
Differential Revision: https://reviews.llvm.org/D79204
Added:
Modified:
clang/unittests/Format/CleanupTest.cpp
clang/unittests/Format/FormatTestCSharp.cpp
clang/unittests/Format/FormatTestComments.cpp
clang/unittests/Format/FormatTestJS.cpp
clang/unittests/Format/FormatTestJava.cpp
clang/unittests/Format/FormatTestObjC.cpp
clang/unittests/Format/FormatTestProto.cpp
clang/unittests/Format/FormatTestRawStrings.cpp
clang/unittests/Format/FormatTestSelective.cpp
clang/unittests/Format/FormatTestTextProto.cpp
clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
clang/unittests/Format/SortIncludesTest.cpp
clang/unittests/Format/UsingDeclarationsSorterTest.cpp
Removed:
################################################################################
diff --git a/clang/unittests/Format/CleanupTest.cpp b/clang/unittests/Format/CleanupTest.cpp
index 70741d239c82..9649b981d558 100644
--- a/clang/unittests/Format/CleanupTest.cpp
+++ b/clang/unittests/Format/CleanupTest.cpp
@@ -479,7 +479,6 @@ TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCodeMultipleInsertions) {
EXPECT_EQ(Expected, apply(Code, Replaces));
}
-
TEST_F(CleanUpReplacementsTest, FormatCorrectLineWhenHeadersAreInserted) {
std::string Code = "\n"
"int x;\n"
diff --git a/clang/unittests/Format/FormatTestCSharp.cpp b/clang/unittests/Format/FormatTestCSharp.cpp
index 40367906c423..d8d992e091d9 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -761,7 +761,8 @@ TEST_F(FormatTestCSharp, CSharpGenericTypeConstraints) {
verifyFormat(R"(//
class ItemFactory<T>
- where T : new() {})", Style);
+ where T : new() {})",
+ Style);
verifyFormat(R"(//
class Dictionary<TKey, TVal>
diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp
index 6dbc364fd255..d5b9f8e0885a 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -28,11 +28,7 @@ FormatStyle getGoogleStyle() { return getGoogleStyle(FormatStyle::LK_Cpp); }
class FormatTestComments : public ::testing::Test {
protected:
- enum StatusCheck {
- SC_ExpectComplete,
- SC_ExpectIncomplete,
- SC_DoNotCheck
- };
+ enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
std::string format(llvm::StringRef Code,
const FormatStyle &Style = getLLVMStyle(),
@@ -649,7 +645,8 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
"//!line 4\n"
"//!line 5\n"
"// line 6\n"
- "//line 7", getLLVMStyleWithColumns(20)));
+ "//line 7",
+ getLLVMStyleWithColumns(20)));
EXPECT_EQ("// aa bb cc dd",
format("// aa bb cc dd ",
@@ -1346,7 +1343,8 @@ TEST_F(FormatTestComments, KeepsTrailingPPCommentsAndSectionCommentsSeparate) {
" // section comment 3\n"
" i = 4;\n"
"#endif\n"
- "}", getLLVMStyleWithColumns(80));
+ "}",
+ getLLVMStyleWithColumns(80));
}
TEST_F(FormatTestComments, AlignsPPElseEndifComments) {
@@ -1824,14 +1822,13 @@ TEST_F(FormatTestComments, ReflowsComments) {
// Reflow the last two lines of a section that starts with a line having
//
diff erent indentation.
- EXPECT_EQ(
- "// long\n"
- "// long long long\n"
- "// long long",
- format("// long\n"
- "// long long long long\n"
- "// long",
- getLLVMStyleWithColumns(20)));
+ EXPECT_EQ("// long\n"
+ "// long long long\n"
+ "// long long",
+ format("// long\n"
+ "// long long long long\n"
+ "// long",
+ getLLVMStyleWithColumns(20)));
// Keep the block comment endling '*/' while reflowing.
EXPECT_EQ("/* Long long long\n"
@@ -1911,10 +1908,9 @@ TEST_F(FormatTestComments, ReflowsComments) {
EXPECT_EQ("// long long long\n"
"// long\n"
"// ... --- ...",
- format(
- "// long long long long\n"
- "// ... --- ...",
- getLLVMStyleWithColumns(20)));
+ format("// long long long long\n"
+ "// ... --- ...",
+ getLLVMStyleWithColumns(20)));
// Don't reflow lines starting with '@'.
EXPECT_EQ("// long long long\n"
@@ -1968,10 +1964,9 @@ TEST_F(FormatTestComments, ReflowsComments) {
// characters.
EXPECT_EQ("// long long long\n"
"// long 'long'",
- format(
- "// long long long long\n"
- "// 'long'",
- getLLVMStyleWithColumns(20)));
+ format("// long long long long\n"
+ "// 'long'",
+ getLLVMStyleWithColumns(20)));
// Don't reflow between separate blocks of comments.
EXPECT_EQ("/* First comment\n"
@@ -2420,7 +2415,7 @@ TEST_F(FormatTestComments, BlockComments) {
format("int aaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
" /* line 1\n"
" bbbbbbbbbbbb */ bbbbbbbbbbbbbbbbbbbbbbbbbbbb;",
- getLLVMStyleWithColumns(50)));
+ getLLVMStyleWithColumns(50)));
FormatStyle NoBinPacking = getLLVMStyle();
NoBinPacking.BinPackParameters = false;
@@ -2791,15 +2786,18 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
EXPECT_EQ("/*\n"
" */",
format("/*\n"
- "*/", getLLVMStyle()));
+ "*/",
+ getLLVMStyle()));
EXPECT_EQ("/*\n"
" */",
format("/*\n"
- " */", getLLVMStyle()));
+ " */",
+ getLLVMStyle()));
EXPECT_EQ("/*\n"
" */",
format("/*\n"
- " */", getLLVMStyle()));
+ " */",
+ getLLVMStyle()));
// Align a single line.
EXPECT_EQ("/*\n"
@@ -2854,19 +2852,22 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
" */",
format("/*\n"
"* line\n"
- "*/", getLLVMStyle()));
+ "*/",
+ getLLVMStyle()));
EXPECT_EQ("/*\n"
" * line\n"
" */",
format("/*\n"
" * line\n"
- " */", getLLVMStyle()));
+ " */",
+ getLLVMStyle()));
EXPECT_EQ("/*\n"
" * line\n"
" */",
format("/*\n"
" * line\n"
- " */", getLLVMStyle()));
+ " */",
+ getLLVMStyle()));
// Align two lines.
EXPECT_EQ("/* line 1\n"
@@ -2947,7 +2948,8 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
" * line 2\n"
" * line 3\n"
"* line 4\n"
- "*/", getLLVMStyle()));
+ "*/",
+ getLLVMStyle()));
// Align empty or blank lines.
EXPECT_EQ("/**\n"
@@ -2959,7 +2961,8 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
"* \n"
" * \n"
" *\n"
- "*/", getLLVMStyle()));
+ "*/",
+ getLLVMStyle()));
// Align while breaking and reflowing.
EXPECT_EQ("/*\n"
@@ -3096,7 +3099,7 @@ TEST_F(FormatTestComments, BreaksBeforeTrailingUnbreakableSequence) {
}
TEST_F(FormatTestComments, ReflowBackslashCrash) {
-// clang-format off
+ // clang-format off
EXPECT_EQ(
"// How to run:\n"
"// bbbbb run \\\n"
@@ -3107,7 +3110,7 @@ TEST_F(FormatTestComments, ReflowBackslashCrash) {
"// bbbbb run \\\n"
"// rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr \\\n"
"// <log_file> -- --output_directory=\"<output_directory>\""));
-// clang-format on
+ // clang-format on
}
TEST_F(FormatTestComments, IndentsLongJavadocAnnotatedLines) {
@@ -3143,18 +3146,18 @@ TEST_F(FormatTestComments, IndentsLongJavadocAnnotatedLines) {
"long long long long long long long long long long long\n"
" */\n",
Style));
- EXPECT_EQ(
- "/**\n"
- " * Sentence that\n"
- " * should be broken.\n"
- " * @param short\n"
- " * keep indentation\n"
- " */\n", format(
- "/**\n"
- " * Sentence that should be broken.\n"
- " * @param short\n"
- " * keep indentation\n"
- " */\n", Style20));
+ EXPECT_EQ("/**\n"
+ " * Sentence that\n"
+ " * should be broken.\n"
+ " * @param short\n"
+ " * keep indentation\n"
+ " */\n",
+ format("/**\n"
+ " * Sentence that should be broken.\n"
+ " * @param short\n"
+ " * keep indentation\n"
+ " */\n",
+ Style20));
EXPECT_EQ("/**\n"
" * @param l1 long1\n"
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index eadea35f051a..07e25e8e1a79 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -48,15 +48,13 @@ class FormatTestJS : public ::testing::Test {
static void verifyFormat(
llvm::StringRef Code,
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
- EXPECT_EQ(Code.str(), format(Code, Style))
- << "Expected code is not stable";
+ EXPECT_EQ(Code.str(), format(Code, Style)) << "Expected code is not stable";
std::string Result = format(test::messUp(Code), Style);
EXPECT_EQ(Code.str(), Result) << "Formatted:\n" << Result;
}
static void verifyFormat(
- llvm::StringRef Expected,
- llvm::StringRef Code,
+ llvm::StringRef Expected, llvm::StringRef Code,
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
EXPECT_EQ(Expected.str(), format(Expected, Style))
<< "Expected code is not stable";
@@ -115,7 +113,8 @@ TEST_F(FormatTestJS, JSDocComments) {
" * jsdoc line 1\n"
" */",
format("/** jsdoc line 1\n"
- " */", getGoogleJSStyleWithColumns(20)));
+ " */",
+ 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)));
@@ -185,8 +184,7 @@ TEST_F(FormatTestJS, JSDocComments) {
// Don't break the first line of a single line short jsdoc comment pragma.
EXPECT_EQ("/** @returns j */",
- format("/** @returns j */",
- getGoogleJSStyleWithColumns(20)));
+ format("/** @returns j */", getGoogleJSStyleWithColumns(20)));
// Break a single line long jsdoc comment pragma.
EXPECT_EQ("/**\n"
@@ -346,18 +344,17 @@ TEST_F(FormatTestJS, ReservedWords) {
}
TEST_F(FormatTestJS, ReservedWordsMethods) {
- verifyFormat(
- "class X {\n"
- " delete() {\n"
- " x();\n"
- " }\n"
- " interface() {\n"
- " x();\n"
- " }\n"
- " let() {\n"
- " x();\n"
- " }\n"
- "}\n");
+ verifyFormat("class X {\n"
+ " delete() {\n"
+ " x();\n"
+ " }\n"
+ " interface() {\n"
+ " x();\n"
+ " }\n"
+ " let() {\n"
+ " x();\n"
+ " }\n"
+ "}\n");
verifyFormat("class KeywordNamedMethods {\n"
" do() {\n"
" }\n"
@@ -638,25 +635,27 @@ TEST_F(FormatTestJS, FormatsNamespaces) {
TEST_F(FormatTestJS, NamespacesMayNotWrap) {
verifyFormat("declare namespace foobarbaz {\n"
- "}\n", getGoogleJSStyleWithColumns(18));
+ "}\n",
+ getGoogleJSStyleWithColumns(18));
verifyFormat("declare module foobarbaz {\n"
- "}\n", getGoogleJSStyleWithColumns(15));
+ "}\n",
+ getGoogleJSStyleWithColumns(15));
verifyFormat("namespace foobarbaz {\n"
- "}\n", getGoogleJSStyleWithColumns(10));
+ "}\n",
+ getGoogleJSStyleWithColumns(10));
verifyFormat("module foobarbaz {\n"
- "}\n", getGoogleJSStyleWithColumns(7));
+ "}\n",
+ getGoogleJSStyleWithColumns(7));
}
TEST_F(FormatTestJS, AmbientDeclarations) {
FormatStyle NineCols = getGoogleJSStyleWithColumns(9);
- verifyFormat(
- "declare class\n"
- " X {}",
- NineCols);
- verifyFormat(
- "declare function\n"
- "x();", // TODO(martinprobst): should ideally be indented.
- NineCols);
+ verifyFormat("declare class\n"
+ " X {}",
+ NineCols);
+ verifyFormat("declare function\n"
+ "x();", // TODO(martinprobst): should ideally be indented.
+ NineCols);
verifyFormat("declare function foo();\n"
"let x = 1;\n");
verifyFormat("declare function foo(): string;\n"
@@ -667,14 +666,12 @@ TEST_F(FormatTestJS, AmbientDeclarations) {
"let x = 1;\n");
verifyFormat("declare interface Y {}\n"
"let x = 1;\n");
- verifyFormat(
- "declare enum X {\n"
- "}",
- NineCols);
- verifyFormat(
- "declare let\n"
- " x: number;",
- NineCols);
+ verifyFormat("declare enum X {\n"
+ "}",
+ NineCols);
+ verifyFormat("declare let\n"
+ " x: number;",
+ NineCols);
}
TEST_F(FormatTestJS, FormatsFreestandingFunctions) {
@@ -1012,7 +1009,6 @@ TEST_F(FormatTestJS, FunctionLiterals) {
" a: function() { return 1; }\n"
"});",
Style);
-
}
TEST_F(FormatTestJS, DontWrapEmptyLiterals) {
@@ -1206,15 +1202,13 @@ TEST_F(FormatTestJS, ArrowFunctionStyle) {
" x;\n"
"};",
Style);
- verifyFormat("const arrInlineEmpty = () => {};",
- Style);
+ verifyFormat("const arrInlineEmpty = () => {};", Style);
Style.AllowShortLambdasOnASingleLine = FormatStyle::SLS_Inline;
verifyFormat("const arr = () => {\n"
" x;\n"
"};",
Style);
- verifyFormat("foo(() => {});",
- Style);
+ verifyFormat("foo(() => {});", Style);
verifyFormat("const arrInlineInline = () => {};", Style);
}
@@ -1359,43 +1353,36 @@ TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {
"a = null\n"
" return 1");
// Below "class Y {}" should ideally be on its own line.
- verifyFormat(
- "x = {\n"
- " a: 1\n"
- "} class Y {}",
- " x = {a : 1}\n"
- " class Y { }");
- verifyFormat(
- "if (x) {\n"
- "}\n"
- "return 1",
- "if (x) {}\n"
- " return 1");
- verifyFormat(
- "if (x) {\n"
- "}\n"
- "class X {}",
- "if (x) {}\n"
- " class X {}");
+ verifyFormat("x = {\n"
+ " a: 1\n"
+ "} class Y {}",
+ " x = {a : 1}\n"
+ " class Y { }");
+ verifyFormat("if (x) {\n"
+ "}\n"
+ "return 1",
+ "if (x) {}\n"
+ " return 1");
+ verifyFormat("if (x) {\n"
+ "}\n"
+ "class X {}",
+ "if (x) {}\n"
+ " class X {}");
}
TEST_F(FormatTestJS, ImportExportASI) {
- verifyFormat(
- "import {x} from 'y'\n"
- "export function z() {}",
- "import {x} from 'y'\n"
- " export function z() {}");
+ verifyFormat("import {x} from 'y'\n"
+ "export function z() {}",
+ "import {x} from 'y'\n"
+ " export function z() {}");
// Below "class Y {}" should ideally be on its own line.
- verifyFormat(
- "export {x} class Y {}",
- " export {x}\n"
- " class Y {\n}");
- verifyFormat(
- "if (x) {\n"
- "}\n"
- "export class Y {}",
- "if ( x ) { }\n"
- " export class Y {}");
+ verifyFormat("export {x} class Y {}", " export {x}\n"
+ " class Y {\n}");
+ verifyFormat("if (x) {\n"
+ "}\n"
+ "export class Y {}",
+ "if ( x ) { }\n"
+ " export class Y {}");
}
TEST_F(FormatTestJS, ClosureStyleCasts) {
@@ -1576,8 +1563,9 @@ TEST_F(FormatTestJS, TypeAnnotations) {
verifyFormat(
"var someValue = (v as aaaaaaaaaaaaaaaaaaaa<T>[])\n"
" .someFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
- verifyFormat("const xIsALongIdent:\n"" YJustBarelyFitsLinex[];",
- getGoogleJSStyleWithColumns(20));
+ verifyFormat("const xIsALongIdent:\n"
+ " YJustBarelyFitsLinex[];",
+ getGoogleJSStyleWithColumns(20));
verifyFormat("const x = {\n"
" y: 1\n"
"} as const;");
@@ -1630,10 +1618,9 @@ TEST_F(FormatTestJS, ClassDeclarations) {
verifyFormat("class C {\n static x(): string {\n return 'asd';\n }\n}");
verifyFormat("class C extends P implements I {}");
verifyFormat("class C extends p.P implements i.I {}");
- verifyFormat(
- "x(class {\n"
- " a(): A {}\n"
- "});");
+ verifyFormat("x(class {\n"
+ " a(): A {}\n"
+ "});");
verifyFormat("class Test {\n"
" aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaa):\n"
" aaaaaaaaaaaaaaaaaaaaaa {}\n"
@@ -1765,14 +1752,12 @@ TEST_F(FormatTestJS, TypeInterfaceLineWrapping) {
const FormatStyle &Style = getGoogleJSStyleWithColumns(20);
verifyFormat("type LongTypeIsReallyUnreasonablyLong =\n"
" string;\n",
- "type LongTypeIsReallyUnreasonablyLong = string;\n",
+ "type LongTypeIsReallyUnreasonablyLong = string;\n", Style);
+ verifyFormat("interface AbstractStrategyFactoryProvider {\n"
+ " a: number\n"
+ "}\n",
+ "interface AbstractStrategyFactoryProvider { a: number }\n",
Style);
- verifyFormat(
- "interface AbstractStrategyFactoryProvider {\n"
- " a: number\n"
- "}\n",
- "interface AbstractStrategyFactoryProvider { a: number }\n",
- Style);
}
TEST_F(FormatTestJS, RemoveEmptyLinesInArrowFunctions) {
@@ -1912,11 +1897,11 @@ TEST_F(FormatTestJS, ImportWrapping) {
TEST_F(FormatTestJS, TemplateStrings) {
// Keeps any whitespace/indentation within the template string.
verifyFormat("var x = `hello\n"
- " ${name}\n"
- " !`;",
- "var x = `hello\n"
- " ${ name }\n"
- " !`;");
+ " ${name}\n"
+ " !`;",
+ "var x = `hello\n"
+ " ${ name }\n"
+ " !`;");
verifyFormat("var x =\n"
" `hello ${world}` >= some();",
@@ -1926,18 +1911,18 @@ TEST_F(FormatTestJS, TemplateStrings) {
verifyFormat("var x = `hellö ${wörld}` >= söme();",
getGoogleJSStyleWithColumns(35)); // Fits due to UTF-8.
verifyFormat("var x = `hello\n"
- " ${world}` >=\n"
- " some();",
- "var x =\n"
- " `hello\n"
- " ${world}` >= some();",
- getGoogleJSStyleWithColumns(21)); // Barely doesn't fit.
+ " ${world}` >=\n"
+ " some();",
+ "var x =\n"
+ " `hello\n"
+ " ${world}` >= some();",
+ getGoogleJSStyleWithColumns(21)); // Barely doesn't fit.
verifyFormat("var x = `hello\n"
- " ${world}` >= some();",
- "var x =\n"
- " `hello\n"
- " ${world}` >= some();",
- getGoogleJSStyleWithColumns(22)); // Barely fits.
+ " ${world}` >= some();",
+ "var x =\n"
+ " `hello\n"
+ " ${world}` >= some();",
+ getGoogleJSStyleWithColumns(22)); // Barely fits.
verifyFormat("var x =\n"
" `h`;",
@@ -1956,18 +1941,17 @@ TEST_F(FormatTestJS, TemplateStrings) {
// Make sure template strings get a proper ColumnWidth assigned, even if they
// are first token in line.
- verifyFormat(
- "var a = aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
- " `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`;");
+ verifyFormat("var a = aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
+ " `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`;");
// Two template strings.
verifyFormat("var x = `hello` == `hello`;");
// Comments in template strings.
verifyFormat("var x = `//a`;\n"
- "var y;",
- "var x =\n `//a`;\n"
- "var y ;");
+ "var y;",
+ "var x =\n `//a`;\n"
+ "var y ;");
verifyFormat("var x = `/*a`;\n"
"var y;",
"var x =\n `/*a`;\n"
@@ -2207,16 +2191,15 @@ TEST_F(FormatTestJS, JSDocAnnotations) {
" * @see http://very/very/long/url/is/long\n"
" */",
getGoogleJSStyleWithColumns(20));
- verifyFormat(
- "/**\n"
- " * @param This is a\n"
- " * long comment\n"
- " * but no type\n"
- " */",
- "/**\n"
- " * @param This is a long comment but no type\n"
- " */",
- getGoogleJSStyleWithColumns(20));
+ verifyFormat("/**\n"
+ " * @param This is a\n"
+ " * long comment\n"
+ " * but no type\n"
+ " */",
+ "/**\n"
+ " * @param This is a long comment but no type\n"
+ " */",
+ getGoogleJSStyleWithColumns(20));
// Break and reindent @param line and reflow unrelated lines.
EXPECT_EQ("{\n"
" /**\n"
@@ -2277,12 +2260,11 @@ TEST_F(FormatTestJS, RequoteStringsSingle) {
verifyFormat("var x = 'foo';", "var x = \"foo\";");
verifyFormat("var x = 'fo\\'o\\'';", "var x = \"fo'o'\";");
verifyFormat("var x = 'fo\\'o\\'';", "var x = \"fo\\'o'\";");
- verifyFormat(
- "var x =\n"
- " 'foo\\'';",
- // Code below is 15 chars wide, doesn't fit into the line with the
- // \ escape added.
- "var x = \"foo'\";", getGoogleJSStyleWithColumns(15));
+ verifyFormat("var x =\n"
+ " 'foo\\'';",
+ // Code below is 15 chars wide, doesn't fit into the line with
+ // the \ escape added.
+ "var x = \"foo'\";", getGoogleJSStyleWithColumns(15));
// Removes no-longer needed \ escape from ".
verifyFormat("var x = 'fo\"o';", "var x = \"fo\\\"o\";");
// Code below fits into 15 chars *after* removing the \ escape.
@@ -2343,18 +2325,16 @@ TEST_F(FormatTestJS, NonNullAssertionOperator) {
verifyFormat("let x = foo[0]!;\n");
verifyFormat("let x = (foo)!;\n");
verifyFormat("let x = x(foo!);\n");
- verifyFormat(
- "a.aaaaaa(a.a!).then(\n"
- " x => x(x));\n",
- getGoogleJSStyleWithColumns(20));
+ verifyFormat("a.aaaaaa(a.a!).then(\n"
+ " x => x(x));\n",
+ getGoogleJSStyleWithColumns(20));
verifyFormat("let x = foo! - 1;\n");
verifyFormat("let x = {foo: 1}!;\n");
- verifyFormat(
- "let x = hello.foo()!\n"
- " .foo()!\n"
- " .foo()!\n"
- " .foo()!;\n",
- getGoogleJSStyleWithColumns(20));
+ verifyFormat("let x = hello.foo()!\n"
+ " .foo()!\n"
+ " .foo()!\n"
+ " .foo()!;\n",
+ getGoogleJSStyleWithColumns(20));
verifyFormat("let x = namespace!;\n");
verifyFormat("return !!x;\n");
}
@@ -2447,7 +2427,8 @@ TEST_F(FormatTestJS, ImportComments) {
verifyFormat("import {x} from 'x'; // from some location",
getGoogleJSStyleWithColumns(25));
verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
- verifyFormat("/// <reference path=\"some/location\" />", getGoogleJSStyleWithColumns(10));
+ verifyFormat("/// <reference path=\"some/location\" />",
+ getGoogleJSStyleWithColumns(10));
}
TEST_F(FormatTestJS, Exponentiation) {
@@ -2462,36 +2443,42 @@ TEST_F(FormatTestJS, NestedLiterals) {
" [\n"
" 1,\n"
" ],\n"
- "];", FourSpaces);
+ "];",
+ FourSpaces);
verifyFormat("var l = [\n"
" {\n"
" 1: 1,\n"
" },\n"
- "];", FourSpaces);
+ "];",
+ FourSpaces);
verifyFormat("someFunction(\n"
" p1,\n"
" [\n"
" 1,\n"
" ],\n"
- ");", FourSpaces);
+ ");",
+ FourSpaces);
verifyFormat("someFunction(\n"
" p1,\n"
" {\n"
" 1: 1,\n"
" },\n"
- ");", FourSpaces);
+ ");",
+ FourSpaces);
verifyFormat("var o = {\n"
" 1: 1,\n"
" 2: {\n"
" 3: 3,\n"
" },\n"
- "};", FourSpaces);
+ "};",
+ FourSpaces);
verifyFormat("var o = {\n"
" 1: 1,\n"
" 2: [\n"
" 3,\n"
" ],\n"
- "};", FourSpaces);
+ "};",
+ FourSpaces);
}
TEST_F(FormatTestJS, BackslashesInComments) {
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index 5e73e4b4ea4e..9a18c2853abc 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -337,12 +337,12 @@ TEST_F(FormatTestJava, Annotations) {
"List<Integer> list;");
verifyFormat(
- "@Test\n"
- "@Feature({\"Android-TabSwitcher\"})\n"
- "@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})\n"
- "@Features.EnableFeatures({FEATURE})\n"
- "public void test(@Foo.bar(\"baz\") @Quux.Qoob int theFirstParaaaaam,\n"
- " @Foo.bar(\"baz\") @Quux.Qoob int theSecondParaaaaaaaaaaaaaaaam) {}");
+ "@Test\n"
+ "@Feature({\"Android-TabSwitcher\"})\n"
+ "@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})\n"
+ "@Features.EnableFeatures({FEATURE})\n"
+ "public void test(@Foo.bar(\"baz\") @Quux.Qoob int theFirstParaaaaam,\n"
+ " @Foo.bar(\"baz\") @Quux.Qoob int theSecondParaaaaaaaaaaaaaaaam) {}");
}
TEST_F(FormatTestJava, Generics) {
@@ -460,19 +460,18 @@ TEST_F(FormatTestJava, MethodDeclarations) {
}
TEST_F(FormatTestJava, MethodReference) {
- EXPECT_EQ(
- "private void foo() {\n"
- " f(this::methodReference);\n"
- " f(C.super::methodReference);\n"
- " Consumer<String> c = System.out::println;\n"
- " Iface<Integer> mRef = Ty::<Integer>meth;\n"
- "}",
- format("private void foo() {\n"
- " f(this ::methodReference);\n"
- " f(C.super ::methodReference);\n"
- " Consumer<String> c = System.out ::println;\n"
- " Iface<Integer> mRef = Ty :: <Integer> meth;\n"
- "}"));
+ EXPECT_EQ("private void foo() {\n"
+ " f(this::methodReference);\n"
+ " f(C.super::methodReference);\n"
+ " Consumer<String> c = System.out::println;\n"
+ " Iface<Integer> mRef = Ty::<Integer>meth;\n"
+ "}",
+ format("private void foo() {\n"
+ " f(this ::methodReference);\n"
+ " f(C.super ::methodReference);\n"
+ " Consumer<String> c = System.out ::println;\n"
+ " Iface<Integer> mRef = Ty :: <Integer> meth;\n"
+ "}"));
}
TEST_F(FormatTestJava, CppKeywords) {
@@ -575,16 +574,15 @@ TEST_F(FormatTestJava, KeepsDelimitersOnOwnLineInJavaDocComments) {
}
TEST_F(FormatTestJava, RetainsLogicalShifts) {
- verifyFormat("void f() {\n"
- " int a = 1;\n"
- " a >>>= 1;\n"
- "}");
- verifyFormat("void f() {\n"
- " int a = 1;\n"
- " a = a >>> 1;\n"
- "}");
+ verifyFormat("void f() {\n"
+ " int a = 1;\n"
+ " a >>>= 1;\n"
+ "}");
+ verifyFormat("void f() {\n"
+ " int a = 1;\n"
+ " a = a >>> 1;\n"
+ "}");
}
-
-} // end namespace tooling
+} // namespace format
} // end namespace clang
diff --git a/clang/unittests/Format/FormatTestObjC.cpp b/clang/unittests/Format/FormatTestObjC.cpp
index 42e2a80783be..d73d090a8ba3 100644
--- a/clang/unittests/Format/FormatTestObjC.cpp
+++ b/clang/unittests/Format/FormatTestObjC.cpp
@@ -31,11 +31,7 @@ class FormatTestObjC : public ::testing::Test {
Style.Language = FormatStyle::LK_ObjC;
}
- enum StatusCheck {
- SC_ExpectComplete,
- SC_ExpectIncomplete,
- SC_DoNotCheck
- };
+ enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
std::string format(llvm::StringRef Code,
StatusCheck CheckComplete = SC_ExpectComplete) {
@@ -69,24 +65,28 @@ class FormatTestObjC : public ::testing::Test {
};
TEST(FormatTestObjCStyle, DetectsObjCInHeaders) {
- auto Style = getStyle("LLVM", "a.h", "none", "@interface\n"
- "- (id)init;");
+ auto Style = getStyle("LLVM", "a.h", "none",
+ "@interface\n"
+ "- (id)init;");
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
- Style = getStyle("LLVM", "a.h", "none", "@interface\n"
- "+ (id)init;");
+ Style = getStyle("LLVM", "a.h", "none",
+ "@interface\n"
+ "+ (id)init;");
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
- Style = getStyle("LLVM", "a.h", "none", "@interface\n"
- "@end\n"
- "//comment");
+ Style = getStyle("LLVM", "a.h", "none",
+ "@interface\n"
+ "@end\n"
+ "//comment");
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
- Style = getStyle("LLVM", "a.h", "none", "@interface\n"
- "@end //comment");
+ Style = getStyle("LLVM", "a.h", "none",
+ "@interface\n"
+ "@end //comment");
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
@@ -113,13 +113,12 @@ TEST(FormatTestObjCStyle, DetectsObjCInHeaders) {
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
- Style =
- getStyle("{}", "a.h", "none", "typedef NS_ENUM(int, Foo) {};\n");
+ Style = getStyle("{}", "a.h", "none", "typedef NS_ENUM(int, Foo) {};\n");
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
- Style = getStyle("{}", "a.h", "none",
- "typedef NS_CLOSED_ENUM(int, Foo) {};\n");
+ Style =
+ getStyle("{}", "a.h", "none", "typedef NS_CLOSED_ENUM(int, Foo) {};\n");
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
@@ -603,7 +602,7 @@ TEST_F(FormatTestObjC, FormatObjCMethodDeclarations) {
" bbb:(d)cccc;");
verifyFormat("- (void)drawRectOn:(id)surface ofSize:(aaa)height:(bbb)width;");
- // BraceWrapping AfterFunction is respected for ObjC methods
+ // BraceWrapping AfterFunction is respected for ObjC methods
Style = getGoogleStyle(FormatStyle::LK_ObjC);
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
Style.BraceWrapping.AfterFunction = true;
@@ -946,14 +945,16 @@ TEST_F(FormatTestObjC, FormatObjCMethodExpr) {
verifyFormat("[self performSelector:@selector(loadAccessories)\n"
" withObjectOnMainThread:nil\n"
" waitUntilDone:false];");
- verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaaaa\n"
- " performSelectorOnMainThread:@selector(loadAccessories)\n"
- " withObject:nil\n"
- " waitUntilDone:false];");
- verifyFormat("[self // force wrapping\n"
- " performSelectorOnMainThread:@selector(loadAccessories)\n"
- " withObject:nil\n"
- " waitUntilDone:false];");
+ verifyFormat(
+ "[aaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ " performSelectorOnMainThread:@selector(loadAccessories)\n"
+ " withObject:nil\n"
+ " waitUntilDone:false];");
+ verifyFormat(
+ "[self // force wrapping\n"
+ " performSelectorOnMainThread:@selector(loadAccessories)\n"
+ " withObject:nil\n"
+ " waitUntilDone:false];");
}
TEST_F(FormatTestObjC, ObjCAt) {
@@ -1374,7 +1375,7 @@ TEST_F(FormatTestObjC, DisambiguatesCallsFromCppLambdas) {
// verifyFormat("x = ([a foo:bar] >> b->c == 'd');");
}
-TEST_F(FormatTestObjC, DisambiguatesCallsFromStructuredBindings) {
+TEST_F(FormatTestObjC, DisambiguatesCallsFromStructuredBindings) {
verifyFormat("int f() {\n"
" if (a && [f arg])\n"
" return 0;\n"
diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp
index 4258c169e884..1ff7c22a6df7 100644
--- a/clang/unittests/Format/FormatTestProto.cpp
+++ b/clang/unittests/Format/FormatTestProto.cpp
@@ -667,6 +667,5 @@ TEST_F(FormatTestProto, PreventBreaksBetweenKeyAndSubmessages) {
"}");
}
-
-} // end namespace tooling
+} // namespace format
} // end namespace clang
diff --git a/clang/unittests/Format/FormatTestRawStrings.cpp b/clang/unittests/Format/FormatTestRawStrings.cpp
index dc2f6b51807b..31490355468e 100644
--- a/clang/unittests/Format/FormatTestRawStrings.cpp
+++ b/clang/unittests/Format/FormatTestRawStrings.cpp
@@ -140,7 +140,9 @@ TEST_F(FormatTestRawStrings, UsesConfigurationOverBaseStyle) {
FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
EXPECT_EQ(0, parseConfiguration("---\n"
"Language: Cpp\n"
- "BasedOnStyle: Google", &Style).value());
+ "BasedOnStyle: Google",
+ &Style)
+ .value());
Style.RawStringFormats = {{
FormatStyle::LK_Cpp,
{"cpp"},
@@ -178,26 +180,18 @@ t = R"pb(item: 1)pb";)test",
}
TEST_F(FormatTestRawStrings, ReformatsShortRawStringsOnSingleLine) {
- expect_eq(
- R"test(P p = TP(R"pb()pb");)test",
- format(
- R"test(P p = TP(R"pb( )pb");)test",
- getRawStringPbStyleWithColumns(40)));
- expect_eq(
- R"test(P p = TP(R"pb(item_1: 1)pb");)test",
- format(
- R"test(P p = TP(R"pb(item_1:1)pb");)test",
- getRawStringPbStyleWithColumns(40)));
- expect_eq(
- R"test(P p = TP(R"pb(item_1: 1)pb");)test",
- format(
- R"test(P p = TP(R"pb( item_1 : 1 )pb");)test",
- getRawStringPbStyleWithColumns(40)));
- expect_eq(
- R"test(P p = TP(R"pb(item_1: 1 item_2: 2)pb");)test",
- format(
- R"test(P p = TP(R"pb(item_1:1 item_2:2)pb");)test",
- getRawStringPbStyleWithColumns(40)));
+ expect_eq(R"test(P p = TP(R"pb()pb");)test",
+ format(R"test(P p = TP(R"pb( )pb");)test",
+ getRawStringPbStyleWithColumns(40)));
+ expect_eq(R"test(P p = TP(R"pb(item_1: 1)pb");)test",
+ format(R"test(P p = TP(R"pb(item_1:1)pb");)test",
+ getRawStringPbStyleWithColumns(40)));
+ expect_eq(R"test(P p = TP(R"pb(item_1: 1)pb");)test",
+ format(R"test(P p = TP(R"pb( item_1 : 1 )pb");)test",
+ getRawStringPbStyleWithColumns(40)));
+ expect_eq(R"test(P p = TP(R"pb(item_1: 1 item_2: 2)pb");)test",
+ format(R"test(P p = TP(R"pb(item_1:1 item_2:2)pb");)test",
+ getRawStringPbStyleWithColumns(40)));
// Merge two short lines into one.
expect_eq(R"test(
std::string s = R"pb(
@@ -219,10 +213,10 @@ TEST_F(FormatTestRawStrings, BreaksShortRawStringsWhenNeeded) {
expect_eq(R"test(
P p = TP(R"pb(item_1 < 1 >
item_2: { 2 })pb");)test",
- format(
- R"test(
+ format(
+ R"test(
P p = TP(R"pb(item_1<1> item_2:{2})pb");)test",
- getRawStringPbStyleWithColumns(40)));
+ getRawStringPbStyleWithColumns(40)));
}
TEST_F(FormatTestRawStrings, BreaksRawStringsExceedingColumnLimit) {
@@ -247,9 +241,9 @@ P p = TPPPPPPPPPPPPPPP(R"pb(item_1: 1, item_2: 2, item_3: 3)pb");)test",
P p = TP(R"pb(item_1 < 1 >
item_2: < 2 >
item_3 {})pb");)test",
- format(R"test(
+ format(R"test(
P p = TP(R"pb(item_1<1> item_2:<2> item_3{ })pb");)test",
- getRawStringPbStyleWithColumns(40)));
+ getRawStringPbStyleWithColumns(40)));
expect_eq(
R"test(
@@ -552,7 +546,6 @@ ASSERT_TRUE(
format(R"test(
ASSERT_TRUE(ParseFromString(R"pb(item_1: 1 item_2: 2)pb"), ptr);)test",
getRawStringPbStyleWithColumns(40)));
-
}
TEST_F(FormatTestRawStrings, RawStringsInOperands) {
@@ -683,7 +676,6 @@ auto S =
auto S=(count<3)?R"pb(item_1:1)pb":R"pb(item_2:2,item_3:3)pb";
)test",
getRawStringPbStyleWithColumns(40)));
-
}
TEST_F(FormatTestRawStrings, PrefixAndSuffixAlignment) {
@@ -770,8 +762,7 @@ TEST_F(FormatTestRawStrings, DontFormatNonRawStrings) {
TEST_F(FormatTestRawStrings, FormatsRawStringsWithEnclosingFunctionName) {
FormatStyle Style = getRawStringPbStyleWithColumns(40);
- Style.RawStringFormats[0].EnclosingFunctions.push_back(
- "PARSE_TEXT_PROTO");
+ Style.RawStringFormats[0].EnclosingFunctions.push_back("PARSE_TEXT_PROTO");
Style.RawStringFormats[0].EnclosingFunctions.push_back("ParseTextProto");
expect_eq(R"test(a = PARSE_TEXT_PROTO(R"(key: value)");)test",
format(R"test(a = PARSE_TEXT_PROTO(R"(key:value)");)test", Style));
@@ -816,7 +807,8 @@ xxxxxxxaaaaax wwwwwww = _Verxrrrrrrrr(PARSE_TEXT_PROTO(R"pb(
xxxxxxxaaaaax wwwwwww = _Verxrrrrrrrr(PARSE_TEXT_PROTO(R"pb(
Category: aaaaaaaaaaaaaaaaaaaaaaaaaa
)pb"));
-)test", Style));
+)test",
+ Style));
// The '(' in R"pb is at column 61, break.
expect_eq(R"test(
xxxxxxxaaaaax wwwwwww =
@@ -828,14 +820,15 @@ xxxxxxxaaaaax wwwwwww =
xxxxxxxaaaaax wwwwwww = _Verxrrrrrrrrr(PARSE_TEXT_PROTO(R"pb(
Category: aaaaaaaaaaaaaaaaaaaaaaaaaa
)pb"));
-)test", Style));
+)test",
+ Style));
}
TEST_F(FormatTestRawStrings, KeepsRBraceFolloedByMoreLBracesOnSameLine) {
FormatStyle Style = getRawStringPbStyleWithColumns(80);
expect_eq(
- R"test(
+ R"test(
int f() {
if (1) {
TTTTTTTTTTTTTTTTTTTTT s = PARSE_TEXT_PROTO(R"pb(
@@ -849,8 +842,8 @@ int f() {
}
}
)test",
- format(
- R"test(
+ format(
+ R"test(
int f() {
if (1) {
TTTTTTTTTTTTTTTTTTTTT s = PARSE_TEXT_PROTO(R"pb(
@@ -862,14 +855,13 @@ int f() {
}
}
)test",
- Style));
+ Style));
}
TEST_F(FormatTestRawStrings,
DoNotFormatUnrecognizedDelimitersInRecognizedFunctions) {
FormatStyle Style = getRawStringPbStyleWithColumns(60);
- Style.RawStringFormats[0].EnclosingFunctions.push_back(
- "EqualsProto");
+ Style.RawStringFormats[0].EnclosingFunctions.push_back("EqualsProto");
// EqualsProto is a recognized function, but the Raw delimiter is
// unrecognized. Do not touch the string in this case, since it might be
// special.
@@ -933,7 +925,7 @@ int f() {
}
)test",
Style));
-
+
expect_eq(R"test(
int f() {
int a = g(x,
@@ -978,7 +970,8 @@ int f() {
int f() {
int a = g(R"pb(key:
1)pb", 2);
-})test", Style));
+})test",
+ Style));
}
TEST_F(FormatTestRawStrings, IndentsLastParamAfterNewline) {
diff --git a/clang/unittests/Format/FormatTestSelective.cpp b/clang/unittests/Format/FormatTestSelective.cpp
index f031a3dee54a..c88d1b8bd8ba 100644
--- a/clang/unittests/Format/FormatTestSelective.cpp
+++ b/clang/unittests/Format/FormatTestSelective.cpp
@@ -122,7 +122,8 @@ TEST_F(FormatTestSelective, FormatsCommentsLocally) {
"int b;",
format("int a; // comment\n"
"// comment 2\n"
- "int b;", 28, 0));
+ "int b;",
+ 28, 0));
EXPECT_EQ("int aaaaaa; // comment\n"
"int b;\n"
"int c; // unrelated comment",
@@ -585,14 +586,13 @@ TEST_F(FormatTestSelective, StopFormattingWhenLeavingScope) {
TEST_F(FormatTestSelective, SelectivelyRequoteJavaScript) {
Style = getGoogleStyle(FormatStyle::LK_JavaScript);
- EXPECT_EQ(
- "var x = \"a\";\n"
- "var x = 'a';\n"
- "var x = \"a\";",
- format("var x = \"a\";\n"
- "var x = \"a\";\n"
- "var x = \"a\";",
- 20, 0));
+ EXPECT_EQ("var x = \"a\";\n"
+ "var x = 'a';\n"
+ "var x = \"a\";",
+ format("var x = \"a\";\n"
+ "var x = \"a\";\n"
+ "var x = \"a\";",
+ 20, 0));
}
TEST_F(FormatTestSelective, KeepsIndentAfterCommentSectionImport) {
diff --git a/clang/unittests/Format/FormatTestTextProto.cpp b/clang/unittests/Format/FormatTestTextProto.cpp
index dba81fcd3aab..3ae13d172865 100644
--- a/clang/unittests/Format/FormatTestTextProto.cpp
+++ b/clang/unittests/Format/FormatTestTextProto.cpp
@@ -199,7 +199,7 @@ TEST_F(FormatTestTextProto, SupportsAngleBracketMessageFields) {
"field_c: {}");
verifyFormat("field_a < field_b: 1 >,\n"
- "msg_fid: < fiel_b: 123 >,\n"
+ "msg_fid: < fiel_b: 123 >,\n"
"field_c <>");
verifyFormat("field_a < field_b: 1 >\n"
@@ -450,14 +450,16 @@ TEST_F(FormatTestTextProto, FormatsExtensions) {
" bbbbbbbbbbbbbb] { key: value }");
// These go over the column limit intentionally, since the alternative
// [aa..a\n] is worse.
- verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] {\n"
- " key: value\n"
- "}");
- verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] {\n"
- " [type.type] {\n"
- " keyyyyyyyyyyyyyy: valuuuuuuuuuuuuuuuuuuuuuuuuue\n"
- " }\n"
- "}");
+ verifyFormat(
+ "[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] {\n"
+ " key: value\n"
+ "}");
+ verifyFormat(
+ "[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] {\n"
+ " [type.type] {\n"
+ " keyyyyyyyyyyyyyy: valuuuuuuuuuuuuuuuuuuuuuuuuue\n"
+ " }\n"
+ "}");
verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/\n"
" bbbbbbb] {\n"
" [type.type] {\n"
@@ -517,8 +519,7 @@ TEST_F(FormatTestTextProto, FormatsRepeatedListInitializers) {
" 'long'\n"
" ]\n"
"}\n"
- "key: value"
- );
+ "key: value");
FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
Style.ColumnLimit = 60; // To make writing tests easier.
Style.Cpp11BracedListStyle = true;
@@ -555,7 +556,8 @@ TEST_F(FormatTestTextProto, PutsMultipleEntriesInExtensionsOnNewlines) {
" key: value\n"
" key: value\n"
" }\n"
- "}", Style);
+ "}",
+ Style);
}
TEST_F(FormatTestTextProto, BreaksAfterBraceFollowedByClosingBraceOnNextLine) {
@@ -734,5 +736,5 @@ TEST_F(FormatTestTextProto, KeepsAmpersandsNextToKeys) {
"}");
}
-} // end namespace tooling
+} // namespace format
} // end namespace clang
diff --git a/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp b/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
index ad77c747a592..fee8597b4330 100644
--- a/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ b/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -423,8 +423,7 @@ TEST_F(NamespaceEndCommentsFixerTest, AddsNewlineIfNeeded) {
TEST_F(NamespaceEndCommentsFixerTest, DoesNotAddEndCommentForShortNamespace) {
EXPECT_EQ("namespace {}", fixNamespaceEndComments("namespace {}"));
EXPECT_EQ("namespace A {}", fixNamespaceEndComments("namespace A {}"));
- EXPECT_EQ("namespace A { a }",
- fixNamespaceEndComments("namespace A { a }"));
+ EXPECT_EQ("namespace A { a }", fixNamespaceEndComments("namespace A { a }"));
EXPECT_EQ("namespace A { a };",
fixNamespaceEndComments("namespace A { a };"));
}
diff --git a/clang/unittests/Format/SortIncludesTest.cpp b/clang/unittests/Format/SortIncludesTest.cpp
index 7a073a314890..db3ed65d443b 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -38,8 +38,7 @@ class SortIncludesTest : public ::testing::Test {
return *Result;
}
- std::string sort(StringRef Code,
- StringRef FileName = "input.cpp",
+ std::string sort(StringRef Code, StringRef FileName = "input.cpp",
unsigned ExpectedNumRanges = 1) {
return sort(Code, GetCodeRange(Code), FileName, ExpectedNumRanges);
}
@@ -227,7 +226,8 @@ TEST_F(SortIncludesTest, SupportClangFormatOffCStyle) {
"#include <b>\n"
"#include <a>\n"
"#include <c>\n"
- "/* clang-format onwards */\n", "input.h", 2));
+ "/* clang-format onwards */\n",
+ "input.h", 2));
}
TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
@@ -291,7 +291,8 @@ TEST_F(SortIncludesTest, SortsLocallyInEachBlock) {
sort("#include \"a.h\"\n"
"#include \"c.h\"\n"
"\n"
- "#include \"b.h\"\n", "input.h", 0));
+ "#include \"b.h\"\n",
+ "input.h", 0));
}
TEST_F(SortIncludesTest, SortsAllBlocksWhenMerging) {
@@ -762,7 +763,8 @@ TEST_F(SortIncludesTest, DoNotSortLikelyXml) {
sort("<!--;\n"
"#include <b>\n"
"#include <a>\n"
- "-->", "input.h", 0));
+ "-->",
+ "input.h", 0));
}
TEST_F(SortIncludesTest, DoNotOutputReplacementsForSortedBlocksWithRegrouping) {
diff --git a/clang/unittests/Format/UsingDeclarationsSorterTest.cpp b/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
index 0f517d0a6116..cd5d456b1d73 100644
--- a/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
+++ b/clang/unittests/Format/UsingDeclarationsSorterTest.cpp
@@ -343,7 +343,8 @@ TEST_F(UsingDeclarationsSorterTest, SortsPartialRangeOfUsingDeclarations) {
{tooling::Range(19, 1)}));
}
-TEST_F(UsingDeclarationsSorterTest, SortsUsingDeclarationsWithLeadingkComments) {
+TEST_F(UsingDeclarationsSorterTest,
+ SortsUsingDeclarationsWithLeadingkComments) {
EXPECT_EQ("/* comment */ using a;\n"
"/* comment */ using b;",
sortUsingDeclarations("/* comment */ using b;\n"
@@ -366,7 +367,6 @@ TEST_F(UsingDeclarationsSorterTest, DeduplicatesUsingDeclarations) {
"using e;\n"
"using a;\n"
"using e;"));
-
}
} // end namespace
More information about the cfe-commits
mailing list