mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Fixed empty string emitter bug (it now with auto-quote it
This commit is contained in:
@@ -128,6 +128,9 @@ namespace YAML
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IsValidPlainScalar(const std::string& str, bool inFlow, bool allowOnlyAscii) {
|
bool IsValidPlainScalar(const std::string& str, bool inFlow, bool allowOnlyAscii) {
|
||||||
|
if(str.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
// first check the start
|
// first check the start
|
||||||
const RegEx& start = (inFlow ? Exp::PlainScalarInFlow() : Exp::PlainScalar());
|
const RegEx& start = (inFlow ? Exp::PlainScalarInFlow() : Exp::PlainScalar());
|
||||||
if(!start.Matches(str))
|
if(!start.Matches(str))
|
||||||
|
@@ -846,6 +846,14 @@ namespace Test
|
|||||||
out << "Oops";
|
out << "Oops";
|
||||||
desiredOutput = "Hi\n---\nBye\n---\nOops";
|
desiredOutput = "Hi\n---\nBye\n---\nOops";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmptyString(YAML::Emitter& out, std::string& desiredOutput)
|
||||||
|
{
|
||||||
|
out << YAML::BeginMap;
|
||||||
|
out << YAML::Key << "key" << YAML::Value << "";
|
||||||
|
out << YAML::EndMap;
|
||||||
|
desiredOutput = "key: \"\"";
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// incorrect emitting
|
// incorrect emitting
|
||||||
@@ -1058,6 +1066,7 @@ namespace Test
|
|||||||
RunEmitterTest(&Emitter::BoolFormatting, "bool formatting", passed, total);
|
RunEmitterTest(&Emitter::BoolFormatting, "bool formatting", passed, total);
|
||||||
RunEmitterTest(&Emitter::DocStartAndEnd, "doc start and end", passed, total);
|
RunEmitterTest(&Emitter::DocStartAndEnd, "doc start and end", passed, total);
|
||||||
RunEmitterTest(&Emitter::ImplicitDocStart, "implicit doc start", passed, total);
|
RunEmitterTest(&Emitter::ImplicitDocStart, "implicit doc start", passed, total);
|
||||||
|
RunEmitterTest(&Emitter::EmptyString, "empty string", passed, total);
|
||||||
|
|
||||||
RunEmitterErrorTest(&Emitter::ExtraEndSeq, "extra EndSeq", passed, total);
|
RunEmitterErrorTest(&Emitter::ExtraEndSeq, "extra EndSeq", passed, total);
|
||||||
RunEmitterErrorTest(&Emitter::ExtraEndMap, "extra EndMap", passed, total);
|
RunEmitterErrorTest(&Emitter::ExtraEndMap, "extra EndMap", passed, total);
|
||||||
|
Reference in New Issue
Block a user