static void verifyFormat( llvm::StringRef Code, const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) { EXPECT_EQ(Code.str(), format(test::messUp(Code), Style)); }
static std::string format( llvm::StringRef Code, const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) { return format(Code, 0, Code.size(), Style); }
static FormatStyle getGoogleJSStyleWithColumns(unsigned ColumnLimit) { FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript); Style.ColumnLimit = ColumnLimit; return Style; }
static std::string format(llvm::StringRef Code) { FormatStyle Style = getGoogleStyle(FormatStyle::LK_Proto); Style.ColumnLimit = 60; // To make writing tests easier. return format(Code, 0, Code.size(), Style); }
static void verifyFormat( llvm::StringRef Code, const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) { std::string result = format(test::messUp(Code), Style); EXPECT_EQ(Code.str(), result) << "Formatted:\n" << result; }
static void verifyFormat( llvm::StringRef Code, const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_Java)) { EXPECT_EQ(Code.str(), format(Code, Style)) << "Expected code is not stable"; EXPECT_EQ(Code.str(), format(test::messUp(Code), Style)); }
void verifyGoogleFormat(llvm::StringRef Code) { EXPECT_EQ(Code.str(), format(messUp(Code), getGoogleStyle())); }
TEST_F(FormatTestProto, BreaksEntriesOfSubmessagesContainingSubmessages) { FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto); Style.ColumnLimit = 60; // The column limit allows for the keys submessage to be put on 1 line, but we // break it since it contains a submessage an another entry. verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " item: 'aaaaaaaaaaaaaaaa'\n" " sub <>\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " item: 'aaaaaaaaaaaaaaaa'\n" " sub {}\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " sub {}\n" " sub: <>\n" " sub: []\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " item: 'aaaaaaaaaaa'\n" " sub { msg: 1 }\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " item: 'aaaaaaaaaaa'\n" " sub: { msg: 1 }\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " item: 'aaaaaaaaaaa'\n" " sub < msg: 1 >\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " item: 'aaaaaaaaaaa'\n" " sub: [ msg: 1 ]\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: <\n" " item: 'aaaaaaaaaaa'\n" " sub: [ 1, 2 ]\n" " >\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " sub {}\n" " item: 'aaaaaaaaaaaaaaaa'\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " sub: []\n" " item: 'aaaaaaaaaaaaaaaa'\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " sub <>\n" " item: 'aaaaaaaaaaaaaaaa'\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " sub { key: value }\n" " item: 'aaaaaaaaaaaaaaaa'\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " sub: [ 1, 2 ]\n" " item: 'aaaaaaaaaaaaaaaa'\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " sub < sub_2: {} >\n" " item: 'aaaaaaaaaaaaaaaa'\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " item: data\n" " sub: [ 1, 2 ]\n" " item: 'aaaaaaaaaaaaaaaa'\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " key: valueeeeeeee\n" " keys: {\n" " item: data\n" " sub < sub_2: {} >\n" " item: 'aaaaaaaaaaaaaaaa'\n" " }\n" "}"); verifyFormat("option (MyProto.options) = {\n" " sub: {\n" " key: valueeeeeeee\n" " keys: {\n" " sub: [ 1, 2 ]\n" " item: 'aaaaaaaaaaaaaaaa'\n" " }\n" " }\n" "}"); }