parent
33315286ab
commit
51ce663085
@ -708,7 +708,7 @@ Emitter& Emitter::Write(const std::string& str) {
|
|||||||
Utils::ComputeStringFormat(str, m_pState->GetStringFormat(),
|
Utils::ComputeStringFormat(str, m_pState->GetStringFormat(),
|
||||||
m_pState->CurGroupFlowType(), stringEscaping == StringEscaping::NonAscii);
|
m_pState->CurGroupFlowType(), stringEscaping == StringEscaping::NonAscii);
|
||||||
|
|
||||||
if (strFormat == StringFormat::Literal)
|
if (strFormat == StringFormat::Literal || str.size() > 1024)
|
||||||
m_pState->SetMapKeyFormat(YAML::LongKey, FmtScope::Local);
|
m_pState->SetMapKeyFormat(YAML::LongKey, FmtScope::Local);
|
||||||
|
|
||||||
PrepareNode(EmitterNodeType::Scalar);
|
PrepareNode(EmitterNodeType::Scalar);
|
||||||
|
@ -266,6 +266,8 @@ TEST_F(EmitterTest, SimpleLongKey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(EmitterTest, SingleLongKey) {
|
TEST_F(EmitterTest, SingleLongKey) {
|
||||||
|
const std::string shortKey(1024, 'a');
|
||||||
|
const std::string longKey(1025, 'a');
|
||||||
out << BeginMap;
|
out << BeginMap;
|
||||||
out << Key << "age";
|
out << Key << "age";
|
||||||
out << Value << "24";
|
out << Value << "24";
|
||||||
@ -273,9 +275,14 @@ TEST_F(EmitterTest, SingleLongKey) {
|
|||||||
out << Value << "5'9\"";
|
out << Value << "5'9\"";
|
||||||
out << Key << "weight";
|
out << Key << "weight";
|
||||||
out << Value << 145;
|
out << Value << 145;
|
||||||
|
out << Key << shortKey;
|
||||||
|
out << Value << "1";
|
||||||
|
out << Key << longKey;
|
||||||
|
out << Value << "1";
|
||||||
out << EndMap;
|
out << EndMap;
|
||||||
|
|
||||||
ExpectEmit("age: 24\n? height\n: 5'9\"\nweight: 145");
|
ExpectEmit("age: 24\n? height\n: 5'9\"\nweight: 145\n" + shortKey +
|
||||||
|
": 1\n? " + longKey + "\n: 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(EmitterTest, ComplexLongKey) {
|
TEST_F(EmitterTest, ComplexLongKey) {
|
||||||
|
Loading…
Reference in New Issue
Block a user