Skip to content

Commit 36925ce

Browse files
committed
Defined verifyFormat 2 string version, and messed up the string a little bit more.
1 parent c5621a6 commit 36925ce

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

clang/unittests/Format/FormatTestTableGen.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class FormatTestTableGen : public ::testing::Test {
4040
EXPECT_EQ(Code.str(), format(Code)) << "Expected code is not stable";
4141
EXPECT_EQ(Code.str(), format(test::messUp(Code)));
4242
}
43+
44+
static void verifyFormat(llvm::StringRef Result, llvm::StringRef MessedUp) {
45+
EXPECT_EQ(Result, format(MessedUp));
46+
}
4347
};
4448

4549
TEST_F(FormatTestTableGen, FormatStringBreak) {
@@ -109,24 +113,26 @@ TEST_F(FormatTestTableGen, SimpleValue1_SingleLiterals) {
109113
}
110114

111115
TEST_F(FormatTestTableGen, SimpleValue1_MultilineString) {
112-
// verifyFormat does not understand multiline TableGen code-literals
116+
// test::messUp does not understand multiline TableGen code-literals.
117+
// We have to give the result and the strings to format manually.
113118
std::string DefWithCode =
114119
"def SimpleValueCode {\n"
115120
" let Code =\n"
116121
" [{ A TokCode is nothing more than a multi-line string literal "
117122
"delimited by \\[{ and }\\]. It can break across lines and the line "
118-
"breaks are retained in the string. "
123+
"breaks are retained in the string. \n"
119124
"(https://llvm.org/docs/TableGen/ProgRef.html#grammar-token-TokCode)}];\n"
120125
"}\n";
121-
std::string DefWithCodeMessingUp =
122-
"def SimpleValueCode {\n"
123-
" let Code= "
124-
"[{ A TokCode is nothing more than a multi-line string literal "
126+
std::string DefWithCodeMessedUp =
127+
"def SimpleValueCode { let \n"
128+
"Code= \n"
129+
" [{ A TokCode is nothing more than a multi-line string literal "
125130
"delimited by \\[{ and }\\]. It can break across lines and the line "
126-
"breaks are retained in the string. "
127-
"(https://llvm.org/docs/TableGen/ProgRef.html#grammar-token-TokCode)}];\n"
131+
"breaks are retained in the string. \n"
132+
"(https://llvm.org/docs/TableGen/ProgRef.html#grammar-token-TokCode)}] \n"
133+
" ; \n"
128134
" } \n";
129-
EXPECT_EQ(DefWithCode, format(DefWithCodeMessingUp));
135+
verifyFormat(DefWithCode, DefWithCodeMessedUp);
130136
}
131137

132138
TEST_F(FormatTestTableGen, SimpleValue2) {

0 commit comments

Comments
 (0)