static FormatStyle getStyle() { FormatStyle TheStyle = getGoogleStyle(); if (Style == "LLVM") TheStyle = getLLVMStyle(); if (Style == "Chromium") TheStyle = getChromiumStyle(); return TheStyle; }
TEST_F(FormatTest, IncorrectCodeErrorDetection) { EXPECT_EQ("{\n{\n}\n", format("{\n{\n}\n")); EXPECT_EQ("{\n {\n}\n", format("{\n {\n}\n")); EXPECT_EQ("{\n {\n }\n", format("{\n {\n }\n")); EXPECT_EQ("{\n {\n }\n }\n}\n", format("{\n {\n }\n }\n}\n")); FormatStyle Style = getLLVMStyle(); Style.ColumnLimit = 10; EXPECT_EQ("{\n" " {\n" " breakme(\n" " qwe);\n" "}\n", format("{\n" " {\n" " breakme(qwe);\n" "}\n", Style)); }
std::string format(llvm::StringRef Code, const FormatStyle &Style = getLLVMStyle()) { return format(Code, 0, Code.size(), Style); }