From d8bdeb5b518ecad149eced1227f20eb4d0f6f450 Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Sun, 20 May 2012 01:31:57 -0500 Subject: [PATCH] Added failing test for compact map with newline --- test/emittertests.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/emittertests.cpp b/test/emittertests.cpp index 8da5b70..f157ea1 100644 --- a/test/emittertests.cpp +++ b/test/emittertests.cpp @@ -912,6 +912,32 @@ namespace Test desiredOutput = "[31, 0x1f, 037]"; } + void CompactMapWithNewline(YAML::Emitter& out, std::string& desiredOutput) + { + out << YAML::Comment("Characteristics"); + out << YAML::BeginSeq; + out << YAML::BeginMap; + out << YAML::Key << "color" << YAML::Value << "blue"; + out << YAML::Key << "height" << YAML::Value << 120; + out << YAML::EndMap; + out << YAML::Newline << YAML::Newline; + out << YAML::Comment("Skills"); + out << YAML::BeginMap; + out << YAML::Key << "attack" << YAML::Value << 23; + out << YAML::Key << "intelligence" << YAML::Value << 56; + out << YAML::EndMap; + out << YAML::EndSeq; + + desiredOutput = + "# Characteristics\n" + "- color: blue\n" + " height: 120\n" + "\n" + "# Skills\n" + "- attack: 23\n" + " intelligence: 56"; + } + //////////////////////////////////////////////////////////////////////////////////////////////////////// // incorrect emitting @@ -1145,6 +1171,7 @@ namespace Test RunEmitterTest(&Emitter::SetPrecision, "set precision", passed, total); RunEmitterTest(&Emitter::DashInBlockContext, "dash in block context", passed, total); RunEmitterTest(&Emitter::HexAndOct, "hex and oct", passed, total); + RunEmitterTest(&Emitter::CompactMapWithNewline, "compact map with newline", passed, total); RunEmitterErrorTest(&Emitter::ExtraEndSeq, "extra EndSeq", passed, total); RunEmitterErrorTest(&Emitter::ExtraEndMap, "extra EndMap", passed, total);