mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
chore(test/integration): refactor some test cases to their own test.
Plus, check that the content is what we actually expect. Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
This commit is contained in:

committed by
Jesse Beder

parent
1f2b841949
commit
da82fd982c
@@ -366,30 +366,31 @@ TEST(NodeTest, LoadCommaSeparatedStrings) {
|
|||||||
EXPECT_THROW(Load(R"("foo",)"), ParserException);
|
EXPECT_THROW(Load(R"("foo",)"), ParserException);
|
||||||
EXPECT_THROW(Load(R"(,"foo")"), ParserException);
|
EXPECT_THROW(Load(R"(,"foo")"), ParserException);
|
||||||
EXPECT_THROW(Load(R"(,foo)"), ParserException);
|
EXPECT_THROW(Load(R"(,foo)"), ParserException);
|
||||||
|
}
|
||||||
|
|
||||||
const char *doc_ok = R"(
|
struct NewLineStringsTestCase {
|
||||||
top
|
std::string input;
|
||||||
, aa
|
std::string expected_content;
|
||||||
)";
|
bool should_throw;
|
||||||
EXPECT_NO_THROW(Load(doc_ok));
|
};
|
||||||
|
TEST(NodeTest, LoadNewLineStrings) {
|
||||||
const char *doc_ok_2 = R"(
|
std::vector<NewLineStringsTestCase> tests = {
|
||||||
top
|
{"foo\n, bar", "foo , bar", false},
|
||||||
, "aa"
|
{"foo\n, \"bar\"", "foo , \"bar\"", false},
|
||||||
)";
|
{"\"foo\"\n, \"bar\"", "", true},
|
||||||
EXPECT_NO_THROW(Load(doc_ok_2));
|
{"\"foo\"\n, bar", "", true},
|
||||||
|
};
|
||||||
const char *doc_fail = R"(
|
for (const NewLineStringsTestCase& test : tests) {
|
||||||
"top"
|
if (test.should_throw) {
|
||||||
, "aa"
|
EXPECT_THROW(Load(test.input), ParserException);
|
||||||
)";
|
} else {
|
||||||
EXPECT_THROW(Load(doc_fail), ParserException);
|
Node node = Load(test.input);
|
||||||
|
Emitter emitter;
|
||||||
const char *doc_fail_2 = R"(
|
emitter << node;
|
||||||
"top"
|
EXPECT_EQ(NodeType::Scalar, node.Type());
|
||||||
, aa
|
EXPECT_EQ(test.expected_content, std::string(emitter.c_str()));
|
||||||
)";
|
}
|
||||||
EXPECT_THROW(Load(doc_fail_2), ParserException);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(NodeTest, LoadSameLineStrings) {
|
TEST(NodeTest, LoadSameLineStrings) {
|
||||||
|
Reference in New Issue
Block a user