CLion Code Style and Gtest formatting
I have CLion 2017.1 installed on Ubuntu 15.04
I have GoogleTest installed, compiling and working fine.
I'd like to be able to run the CLion C++ Formatter on the unit test source files. It looks like the gtest macros cause the formatter to get confused.
TEST(parser, some_command)
{
EXPECT_EQ(0, 0);
}
Gets reformatted like so:
TEST(parser, some_command
)
{
EXPECT_EQ(0, 0);
}
The trailing ")" gets moved to the next line. All of the lines in the rest of the file get put into column 0.
Is there anything I can do about this?
Is there a workaround?
Thanks
John
请先登录再写评论。
This is still happening. In fact, I am seeing much of the code in GTests get completely munged (for loop declarations spread over multiple lines for no reason). Any updates?
Hi Mjhamiltonus!
Have you tried using ClangFormat instead of the CLion built-in code formatter - https://www.jetbrains.com/help/clion/clangformat-as-alternative-formatter.html? Does it help?
Hello Anna - Switching to clangformat does indeed seem to resolve this. I guess that is a reasonable alternative approach. Thanks!