Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/unittests/Format/FormatTest.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 4,028 Lines • ▼ Show 20 Lines | TEST_F(FormatTest, FormatsNamespaces) { | ||||
verifyFormat("namespace {\n" | verifyFormat("namespace {\n" | ||||
"int SomeVariable = 0; // comment\n" | "int SomeVariable = 0; // comment\n" | ||||
"} // namespace", | "} // namespace", | ||||
LLVMWithNoNamespaceFix); | LLVMWithNoNamespaceFix); | ||||
EXPECT_EQ("#ifndef HEADER_GUARD\n" | EXPECT_EQ("#ifndef HEADER_GUARD\n" | ||||
"#define HEADER_GUARD\n" | "#define HEADER_GUARD\n" | ||||
"namespace my_namespace {\n" | "namespace my_namespace {\n" | ||||
"int i;\n" | "int i;\n" | ||||
"} // my_namespace\n" | "} // my_namespace\n" | ||||
owenpan: This trailing comment was at the correct column and shouldn’t be aligned to the header guard… | |||||
"#endif // HEADER_GUARD", | "#endif // HEADER_GUARD", | ||||
format("#ifndef HEADER_GUARD\n" | format("#ifndef HEADER_GUARD\n" | ||||
" #define HEADER_GUARD\n" | " #define HEADER_GUARD\n" | ||||
" namespace my_namespace {\n" | " namespace my_namespace {\n" | ||||
"int i;\n" | "int i;\n" | ||||
"} // my_namespace\n" | "} // my_namespace\n" | ||||
"#endif // HEADER_GUARD", | "#endif // HEADER_GUARD", | ||||
LLVMWithNoNamespaceFix)); | LLVMWithNoNamespaceFix)); | ||||
▲ Show 20 Lines • Show All 15,168 Lines • ▼ Show 20 Lines | verifyFormat("namespace a\n" | ||||
" return;\n" | " return;\n" | ||||
" }\n" | " }\n" | ||||
" };\n" | " };\n" | ||||
" struct B\n" | " struct B\n" | ||||
" {\n" | " {\n" | ||||
" int x;\n" | " int x;\n" | ||||
" };\n" | " };\n" | ||||
" } // namespace b\n" | " } // namespace b\n" | ||||
" } // namespace a", | " } // namespace a", | ||||
WhitesmithsBraceStyle); | WhitesmithsBraceStyle); | ||||
verifyFormat("void f()\n" | verifyFormat("void f()\n" | ||||
" {\n" | " {\n" | ||||
" if (true)\n" | " if (true)\n" | ||||
" {\n" | " {\n" | ||||
" a();\n" | " a();\n" | ||||
" }\n" | " }\n" | ||||
▲ Show 20 Lines • Show All 5,598 Lines • Show Last 20 Lines |
This trailing comment was at the correct column and shouldn’t be aligned to the header guard comment below it.