File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -708,7 +708,7 @@ Emitter& Emitter::Write(const std::string& str) {
708708 Utils::ComputeStringFormat (str, m_pState->GetStringFormat (),
709709 m_pState->CurGroupFlowType (), stringEscaping == StringEscaping::NonAscii);
710710
711- if (strFormat == StringFormat::Literal)
711+ if (strFormat == StringFormat::Literal || str. size () > 1024 )
712712 m_pState->SetMapKeyFormat (YAML::LongKey, FmtScope::Local);
713713
714714 PrepareNode (EmitterNodeType::Scalar);
Original file line number Diff line number Diff line change @@ -266,16 +266,23 @@ TEST_F(EmitterTest, SimpleLongKey) {
266266}
267267
268268TEST_F (EmitterTest, SingleLongKey) {
269+ const std::string shortKey (1024 , ' a' );
270+ const std::string longKey (1025 , ' a' );
269271 out << BeginMap;
270272 out << Key << " age" ;
271273 out << Value << " 24" ;
272274 out << LongKey << Key << " height" ;
273275 out << Value << " 5'9\" " ;
274276 out << Key << " weight" ;
275277 out << Value << 145 ;
278+ out << Key << shortKey;
279+ out << Value << " 1" ;
280+ out << Key << longKey;
281+ out << Value << " 1" ;
276282 out << EndMap;
277283
278- ExpectEmit (" age: 24\n ? height\n : 5'9\"\n weight: 145" );
284+ ExpectEmit (" age: 24\n ? height\n : 5'9\"\n weight: 145\n " + shortKey +
285+ " : 1\n ? " + longKey + " \n : 1" );
279286}
280287
281288TEST_F (EmitterTest, ComplexLongKey) {
You can’t perform that action at this time.
0 commit comments