|
@@ -200,6 +200,42 @@ TEST_F(FormatTest, RemovesEmptyLines) {
|
|
"int i;\n"
|
|
"int i;\n"
|
|
"}",
|
|
"}",
|
|
getGoogleStyle()));
|
|
getGoogleStyle()));
|
|
|
|
+ EXPECT_EQ("/* something */ namespace N {\n"
|
|
|
|
+ "\n"
|
|
|
|
+ "int i;\n"
|
|
|
|
+ "}",
|
|
|
|
+ format("/* something */ namespace N {\n"
|
|
|
|
+ "\n"
|
|
|
|
+ "int i;\n"
|
|
|
|
+ "}",
|
|
|
|
+ getGoogleStyle()));
|
|
|
|
+ EXPECT_EQ("inline namespace N {\n"
|
|
|
|
+ "\n"
|
|
|
|
+ "int i;\n"
|
|
|
|
+ "}",
|
|
|
|
+ format("inline namespace N {\n"
|
|
|
|
+ "\n"
|
|
|
|
+ "int i;\n"
|
|
|
|
+ "}",
|
|
|
|
+ getGoogleStyle()));
|
|
|
|
+ EXPECT_EQ("/* something */ inline namespace N {\n"
|
|
|
|
+ "\n"
|
|
|
|
+ "int i;\n"
|
|
|
|
+ "}",
|
|
|
|
+ format("/* something */ inline namespace N {\n"
|
|
|
|
+ "\n"
|
|
|
|
+ "int i;\n"
|
|
|
|
+ "}",
|
|
|
|
+ getGoogleStyle()));
|
|
|
|
+ EXPECT_EQ("export namespace N {\n"
|
|
|
|
+ "\n"
|
|
|
|
+ "int i;\n"
|
|
|
|
+ "}",
|
|
|
|
+ format("export namespace N {\n"
|
|
|
|
+ "\n"
|
|
|
|
+ "int i;\n"
|
|
|
|
+ "}",
|
|
|
|
+ getGoogleStyle()));
|
|
EXPECT_EQ("extern /**/ \"C\" /**/ {\n"
|
|
EXPECT_EQ("extern /**/ \"C\" /**/ {\n"
|
|
"\n"
|
|
"\n"
|
|
"int i;\n"
|
|
"int i;\n"
|
|
@@ -1220,12 +1256,25 @@ TEST_F(FormatTest, UnderstandsAccessSpecifiers) {
|
|
"private:\n"
|
|
"private:\n"
|
|
" void f() {}\n"
|
|
" void f() {}\n"
|
|
"};");
|
|
"};");
|
|
|
|
+ verifyFormat("export class A {\n"
|
|
|
|
+ "public:\n"
|
|
|
|
+ "public: // comment\n"
|
|
|
|
+ "protected:\n"
|
|
|
|
+ "private:\n"
|
|
|
|
+ " void f() {}\n"
|
|
|
|
+ "};");
|
|
verifyGoogleFormat("class A {\n"
|
|
verifyGoogleFormat("class A {\n"
|
|
" public:\n"
|
|
" public:\n"
|
|
" protected:\n"
|
|
" protected:\n"
|
|
" private:\n"
|
|
" private:\n"
|
|
" void f() {}\n"
|
|
" void f() {}\n"
|
|
"};");
|
|
"};");
|
|
|
|
+ verifyGoogleFormat("export class A {\n"
|
|
|
|
+ " public:\n"
|
|
|
|
+ " protected:\n"
|
|
|
|
+ " private:\n"
|
|
|
|
+ " void f() {}\n"
|
|
|
|
+ "};");
|
|
verifyFormat("class A {\n"
|
|
verifyFormat("class A {\n"
|
|
"public slots:\n"
|
|
"public slots:\n"
|
|
" void f1() {}\n"
|
|
" void f1() {}\n"
|
|
@@ -1597,16 +1646,36 @@ TEST_F(FormatTest, FormatsNamespaces) {
|
|
"void f() { f(); }\n"
|
|
"void f() { f(); }\n"
|
|
"}",
|
|
"}",
|
|
LLVMWithNoNamespaceFix);
|
|
LLVMWithNoNamespaceFix);
|
|
|
|
+ verifyFormat("/* something */ namespace some_namespace {\n"
|
|
|
|
+ "class A {};\n"
|
|
|
|
+ "void f() { f(); }\n"
|
|
|
|
+ "}",
|
|
|
|
+ LLVMWithNoNamespaceFix);
|
|
verifyFormat("namespace {\n"
|
|
verifyFormat("namespace {\n"
|
|
"class A {};\n"
|
|
"class A {};\n"
|
|
"void f() { f(); }\n"
|
|
"void f() { f(); }\n"
|
|
"}",
|
|
"}",
|
|
LLVMWithNoNamespaceFix);
|
|
LLVMWithNoNamespaceFix);
|
|
|
|
+ verifyFormat("/* something */ namespace {\n"
|
|
|
|
+ "class A {};\n"
|
|
|
|
+ "void f() { f(); }\n"
|
|
|
|
+ "}",
|
|
|
|
+ LLVMWithNoNamespaceFix);
|
|
verifyFormat("inline namespace X {\n"
|
|
verifyFormat("inline namespace X {\n"
|
|
"class A {};\n"
|
|
"class A {};\n"
|
|
"void f() { f(); }\n"
|
|
"void f() { f(); }\n"
|
|
"}",
|
|
"}",
|
|
LLVMWithNoNamespaceFix);
|
|
LLVMWithNoNamespaceFix);
|
|
|
|
+ verifyFormat("/* something */ inline namespace X {\n"
|
|
|
|
+ "class A {};\n"
|
|
|
|
+ "void f() { f(); }\n"
|
|
|
|
+ "}",
|
|
|
|
+ LLVMWithNoNamespaceFix);
|
|
|
|
+ verifyFormat("export namespace X {\n"
|
|
|
|
+ "class A {};\n"
|
|
|
|
+ "void f() { f(); }\n"
|
|
|
|
+ "}",
|
|
|
|
+ LLVMWithNoNamespaceFix);
|
|
verifyFormat("using namespace some_namespace;\n"
|
|
verifyFormat("using namespace some_namespace;\n"
|
|
"class A {};\n"
|
|
"class A {};\n"
|
|
"void f() { f(); }",
|
|
"void f() { f(); }",
|
|
@@ -7602,6 +7671,12 @@ TEST_F(FormatTest, SplitEmptyNamespace) {
|
|
verifyFormat("inline namespace Foo\n"
|
|
verifyFormat("inline namespace Foo\n"
|
|
"{};",
|
|
"{};",
|
|
Style);
|
|
Style);
|
|
|
|
+ verifyFormat("/* something */ inline namespace Foo\n"
|
|
|
|
+ "{};",
|
|
|
|
+ Style);
|
|
|
|
+ verifyFormat("export namespace Foo\n"
|
|
|
|
+ "{};",
|
|
|
|
+ Style);
|
|
verifyFormat("namespace Foo\n"
|
|
verifyFormat("namespace Foo\n"
|
|
"{\n"
|
|
"{\n"
|
|
"void Bar();\n"
|
|
"void Bar();\n"
|