From 62634f53ecba16c29bd2666085daba96c80185f8 Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Mon, 31 Oct 2011 19:16:17 -0500 Subject: [PATCH] Fixed emitter bug with colon at the end of a scalar in a flow collection --- src/exp.h | 2 +- test/emittertests.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/exp.h b/src/exp.h index 703641a..84d14ae 100644 --- a/src/exp.h +++ b/src/exp.h @@ -149,7 +149,7 @@ namespace YAML return e; } inline const RegEx& EndScalarInFlow() { - static const RegEx e = (RegEx(':') + (BlankOrBreak() || RegEx(",]}", REGEX_OR))) || RegEx(",?[]{}", REGEX_OR); + static const RegEx e = (RegEx(':') + (BlankOrBreak() || RegEx() || RegEx(",]}", REGEX_OR))) || RegEx(",?[]{}", REGEX_OR); return e; } diff --git a/test/emittertests.cpp b/test/emittertests.cpp index 7a5febc..ce2114c 100644 --- a/test/emittertests.cpp +++ b/test/emittertests.cpp @@ -790,6 +790,12 @@ namespace Test desiredOutput = "apple: \":\"\nbanana: \":\""; } + void ColonAtEndOfScalarInFlow(YAML::Emitter& out, std::string& desiredOutput) + { + out << YAML::Flow << YAML::BeginMap << YAML::Key << "C:" << YAML::Value << "C:" << YAML::EndMap; + desiredOutput = "{\"C:\": \"C:\"}"; + } + void BoolFormatting(YAML::Emitter& out, std::string& desiredOutput) { out << YAML::BeginSeq; @@ -1068,6 +1074,7 @@ namespace Test RunEmitterTest(&Emitter::EmptyBinary, "empty binary", passed, total); RunEmitterTest(&Emitter::ColonAtEndOfScalar, "colon at end of scalar", passed, total); RunEmitterTest(&Emitter::ColonAsScalar, "colon as scalar", passed, total); + RunEmitterTest(&Emitter::ColonAtEndOfScalarInFlow, "colon at end of scalar in flow", passed, total); RunEmitterTest(&Emitter::BoolFormatting, "bool formatting", passed, total); RunEmitterTest(&Emitter::DocStartAndEnd, "doc start and end", passed, total); RunEmitterTest(&Emitter::ImplicitDocStart, "implicit doc start", passed, total);