From bd58664e8daaebde0a4502d303c32d4cb337e6f3 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Thu, 21 Apr 2022 12:13:04 +0200 Subject: [PATCH] Add testcase showing unquoted & in emit. --- test/integration/emitter_test.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/integration/emitter_test.cpp b/test/integration/emitter_test.cpp index 560f631..53407c9 100644 --- a/test/integration/emitter_test.cpp +++ b/test/integration/emitter_test.cpp @@ -1624,6 +1624,15 @@ NodeB: k: [*k0, *k1])"); } +TEST_F(EmitterTest, AnchorEncoding) { + Node node; + node["--- &$ [*$]1"] = 1; + out << node; + ExpectEmit("\"--- &$ [*$]1\": 1"); + Node reparsed = YAML::Load(out.c_str()); + EXPECT_EQ(reparsed["--- &$ [*$]1"].as(), 1); +} + class EmitterErrorTest : public ::testing::Test { protected: void ExpectEmitError(const std::string& expectedError) { @@ -1694,5 +1703,6 @@ TEST_F(EmitterErrorTest, InvalidAlias) { ExpectEmitError(ErrorMsg::INVALID_ALIAS); } + } // namespace } // namespace YAML