From bcc3e35c034c1659bff6e0446b708dc9d1d018c1 Mon Sep 17 00:00:00 2001 From: theamarin Date: Sat, 3 Jul 2021 23:28:36 +0200 Subject: [PATCH] Add test to ensure that no trailing spaces are generated in literals --- test/node/node_test.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/node/node_test.cpp b/test/node/node_test.cpp index 4f577c8..ac6c785 100644 --- a/test/node/node_test.cpp +++ b/test/node/node_test.cpp @@ -769,5 +769,17 @@ TEST_F(NodeEmitterTest, NestFlowMapListNode) { ExpectOutput("{position: [1.5, 2.25, 3.125]}", mapNode); } + +TEST_F(NodeEmitterTest, LiteralWithoutTrailingSpaces) { + YAML::Emitter emitter; + emitter << YAML::BeginMap; + emitter << YAML::Key << "key"; + emitter << YAML::Literal; + emitter << "value\n\nwith newlines"; + emitter << YAML::EndMap; + + ASSERT_TRUE(emitter.good()); + EXPECT_STREQ("key: |\n value\n\n with newlines", emitter.c_str()); +} } }