Removed the default --- at the start of all emitter output

This commit is contained in:
jbeder
2011-03-03 08:57:00 +00:00
parent f5b09d3ec6
commit 77d20873dc
2 changed files with 68 additions and 68 deletions

View File

@@ -152,8 +152,6 @@ namespace YAML
switch(curState) { switch(curState) {
// document-level // document-level
case ES_WAITING_FOR_DOC: case ES_WAITING_FOR_DOC:
m_stream << "---";
m_pState->RequireSoftSeparation();
m_pState->SwitchState(ES_WRITING_DOC); m_pState->SwitchState(ES_WRITING_DOC);
return true; return true;
case ES_WRITING_DOC: case ES_WRITING_DOC:
@@ -340,8 +338,10 @@ namespace YAML
curState == ES_WRITING_BLOCK_MAP_KEY || curState == ES_WRITING_BLOCK_MAP_VALUE || curState == ES_WRITING_BLOCK_MAP_KEY || curState == ES_WRITING_BLOCK_MAP_VALUE ||
curState == ES_WRITING_DOC curState == ES_WRITING_DOC
) { ) {
m_stream << "\n"; if(m_pState->RequiresHardSeparation() || curState != ES_WRITING_DOC) {
m_pState->UnsetSeparation(); m_stream << "\n";
m_pState->UnsetSeparation();
}
} }
m_pState->PushState(ES_WAITING_FOR_BLOCK_SEQ_ENTRY); m_pState->PushState(ES_WAITING_FOR_BLOCK_SEQ_ENTRY);
} else if(flowType == Flow) { } else if(flowType == Flow) {
@@ -408,7 +408,7 @@ namespace YAML
curState == ES_WRITING_BLOCK_MAP_KEY || curState == ES_WRITING_BLOCK_MAP_VALUE || curState == ES_WRITING_BLOCK_MAP_KEY || curState == ES_WRITING_BLOCK_MAP_VALUE ||
curState == ES_WRITING_DOC curState == ES_WRITING_DOC
) { ) {
if(m_pState->RequiresHardSeparation() || curState != ES_WRITING_BLOCK_SEQ_ENTRY) { if(m_pState->RequiresHardSeparation() || (curState != ES_WRITING_DOC && curState != ES_WRITING_BLOCK_SEQ_ENTRY)) {
m_stream << "\n"; m_stream << "\n";
m_pState->UnsetSeparation(); m_pState->UnsetSeparation();
} }

View File

@@ -9,7 +9,7 @@ namespace Test
void SimpleScalar(YAML::Emitter& out, std::string& desiredOutput) { void SimpleScalar(YAML::Emitter& out, std::string& desiredOutput) {
out << "Hello, World!"; out << "Hello, World!";
desiredOutput = "--- Hello, World!"; desiredOutput = "Hello, World!";
} }
void SimpleSeq(YAML::Emitter& out, std::string& desiredOutput) { void SimpleSeq(YAML::Emitter& out, std::string& desiredOutput) {
@@ -19,7 +19,7 @@ namespace Test
out << "milk"; out << "milk";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- eggs\n- bread\n- milk"; desiredOutput = "- eggs\n- bread\n- milk";
} }
void SimpleFlowSeq(YAML::Emitter& out, std::string& desiredOutput) { void SimpleFlowSeq(YAML::Emitter& out, std::string& desiredOutput) {
@@ -30,7 +30,7 @@ namespace Test
out << "Moe"; out << "Moe";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "--- [Larry, Curly, Moe]"; desiredOutput = "[Larry, Curly, Moe]";
} }
void EmptyFlowSeq(YAML::Emitter& out, std::string& desiredOutput) { void EmptyFlowSeq(YAML::Emitter& out, std::string& desiredOutput) {
@@ -38,7 +38,7 @@ namespace Test
out << YAML::BeginSeq; out << YAML::BeginSeq;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "--- []"; desiredOutput = "[]";
} }
void NestedBlockSeq(YAML::Emitter& out, std::string& desiredOutput) { void NestedBlockSeq(YAML::Emitter& out, std::string& desiredOutput) {
@@ -47,7 +47,7 @@ namespace Test
out << YAML::BeginSeq << "subitem 1" << "subitem 2" << YAML::EndSeq; out << YAML::BeginSeq << "subitem 1" << "subitem 2" << YAML::EndSeq;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- item 1\n-\n - subitem 1\n - subitem 2"; desiredOutput = "- item 1\n-\n - subitem 1\n - subitem 2";
} }
void NestedFlowSeq(YAML::Emitter& out, std::string& desiredOutput) { void NestedFlowSeq(YAML::Emitter& out, std::string& desiredOutput) {
@@ -56,7 +56,7 @@ namespace Test
out << YAML::Flow << YAML::BeginSeq << "two" << "three" << YAML::EndSeq; out << YAML::Flow << YAML::BeginSeq << "two" << "three" << YAML::EndSeq;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- one\n- [two, three]"; desiredOutput = "- one\n- [two, three]";
} }
void SimpleMap(YAML::Emitter& out, std::string& desiredOutput) { void SimpleMap(YAML::Emitter& out, std::string& desiredOutput) {
@@ -67,7 +67,7 @@ namespace Test
out << YAML::Value << "3B"; out << YAML::Value << "3B";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\nname: Ryan Braun\nposition: 3B"; desiredOutput = "name: Ryan Braun\nposition: 3B";
} }
void SimpleFlowMap(YAML::Emitter& out, std::string& desiredOutput) { void SimpleFlowMap(YAML::Emitter& out, std::string& desiredOutput) {
@@ -79,7 +79,7 @@ namespace Test
out << YAML::Value << "blue"; out << YAML::Value << "blue";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "--- {shape: square, color: blue}"; desiredOutput = "{shape: square, color: blue}";
} }
void MapAndList(YAML::Emitter& out, std::string& desiredOutput) { void MapAndList(YAML::Emitter& out, std::string& desiredOutput) {
@@ -90,7 +90,7 @@ namespace Test
out << YAML::Value << YAML::BeginSeq << "Sasha" << "Malia" << YAML::EndSeq; out << YAML::Value << YAML::BeginSeq << "Sasha" << "Malia" << YAML::EndSeq;
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\nname: Barack Obama\nchildren:\n - Sasha\n - Malia"; desiredOutput = "name: Barack Obama\nchildren:\n - Sasha\n - Malia";
} }
void ListAndMap(YAML::Emitter& out, std::string& desiredOutput) { void ListAndMap(YAML::Emitter& out, std::string& desiredOutput) {
@@ -103,7 +103,7 @@ namespace Test
out << "item 2"; out << "item 2";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- item 1\n- pens: 8\n pencils: 14\n- item 2"; desiredOutput = "- item 1\n- pens: 8\n pencils: 14\n- item 2";
} }
void NestedBlockMap(YAML::Emitter& out, std::string& desiredOutput) { void NestedBlockMap(YAML::Emitter& out, std::string& desiredOutput) {
@@ -119,7 +119,7 @@ namespace Test
out << YAML::EndMap; out << YAML::EndMap;
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\nname: Fred\ngrades:\n algebra: A\n physics: C+\n literature: B"; desiredOutput = "name: Fred\ngrades:\n algebra: A\n physics: C+\n literature: B";
} }
void NestedFlowMap(YAML::Emitter& out, std::string& desiredOutput) { void NestedFlowMap(YAML::Emitter& out, std::string& desiredOutput) {
@@ -136,7 +136,7 @@ namespace Test
out << YAML::EndMap; out << YAML::EndMap;
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "--- {name: Fred, grades: {algebra: A, physics: C+, literature: B}}"; desiredOutput = "{name: Fred, grades: {algebra: A, physics: C+, literature: B}}";
} }
void MapListMix(YAML::Emitter& out, std::string& desiredOutput) { void MapListMix(YAML::Emitter& out, std::string& desiredOutput) {
@@ -149,7 +149,7 @@ namespace Test
out << YAML::Key << "invincible" << YAML::Value << YAML::OnOffBool << false; out << YAML::Key << "invincible" << YAML::Value << YAML::OnOffBool << false;
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\nname: Bob\nposition: [2, 4]\ninvincible: off"; desiredOutput = "name: Bob\nposition: [2, 4]\ninvincible: off";
} }
void SimpleLongKey(YAML::Emitter& out, std::string& desiredOutput) void SimpleLongKey(YAML::Emitter& out, std::string& desiredOutput)
@@ -162,7 +162,7 @@ namespace Test
out << YAML::Value << 145; out << YAML::Value << 145;
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\n? height\n: 5'9\"\n? weight\n: 145"; desiredOutput = "? height\n: 5'9\"\n? weight\n: 145";
} }
void SingleLongKey(YAML::Emitter& out, std::string& desiredOutput) void SingleLongKey(YAML::Emitter& out, std::string& desiredOutput)
@@ -176,7 +176,7 @@ namespace Test
out << YAML::Value << 145; out << YAML::Value << 145;
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\nage: 24\n? height\n: 5'9\"\nweight: 145"; desiredOutput = "age: 24\n? height\n: 5'9\"\nweight: 145";
} }
void ComplexLongKey(YAML::Emitter& out, std::string& desiredOutput) void ComplexLongKey(YAML::Emitter& out, std::string& desiredOutput)
@@ -189,7 +189,7 @@ namespace Test
out << YAML::Value << "demon"; out << YAML::Value << "demon";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\n?\n - 1\n - 3\n: monster\n? [2, 0]\n: demon"; desiredOutput = "?\n - 1\n - 3\n: monster\n? [2, 0]\n: demon";
} }
void AutoLongKey(YAML::Emitter& out, std::string& desiredOutput) void AutoLongKey(YAML::Emitter& out, std::string& desiredOutput)
@@ -203,7 +203,7 @@ namespace Test
out << YAML::Value << "angel"; out << YAML::Value << "angel";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\n?\n - 1\n - 3\n: monster\n? [2, 0]\n: demon\nthe origin: angel"; desiredOutput = "?\n - 1\n - 3\n: monster\n? [2, 0]\n: demon\nthe origin: angel";
} }
void ScalarFormat(YAML::Emitter& out, std::string& desiredOutput) void ScalarFormat(YAML::Emitter& out, std::string& desiredOutput)
@@ -217,7 +217,7 @@ namespace Test
out << YAML::Literal << "literal scalar\nthat may span\nmany, many\nlines and have \"whatever\" crazy\tsymbols that we like"; out << YAML::Literal << "literal scalar\nthat may span\nmany, many\nlines and have \"whatever\" crazy\tsymbols that we like";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- simple scalar\n- 'explicit single-quoted scalar'\n- \"explicit double-quoted scalar\"\n- \"auto-detected\\x0adouble-quoted scalar\"\n- a non-\"auto-detected\" double-quoted scalar\n- |\n literal scalar\n that may span\n many, many\n lines and have \"whatever\" crazy\tsymbols that we like"; desiredOutput = "- simple scalar\n- 'explicit single-quoted scalar'\n- \"explicit double-quoted scalar\"\n- \"auto-detected\\x0adouble-quoted scalar\"\n- a non-\"auto-detected\" double-quoted scalar\n- |\n literal scalar\n that may span\n many, many\n lines and have \"whatever\" crazy\tsymbols that we like";
} }
void AutoLongKeyScalar(YAML::Emitter& out, std::string& desiredOutput) void AutoLongKeyScalar(YAML::Emitter& out, std::string& desiredOutput)
@@ -227,7 +227,7 @@ namespace Test
out << YAML::Value << "and its value"; out << YAML::Value << "and its value";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\n? |\n multi-line\n scalar\n: and its value"; desiredOutput = "? |\n multi-line\n scalar\n: and its value";
} }
void LongKeyFlowMap(YAML::Emitter& out, std::string& desiredOutput) void LongKeyFlowMap(YAML::Emitter& out, std::string& desiredOutput)
@@ -240,7 +240,7 @@ namespace Test
out << YAML::Value << "and its value"; out << YAML::Value << "and its value";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "--- {simple key: and value, ? long key: and its value}"; desiredOutput = "{simple key: and value, ? long key: and its value}";
} }
void BlockMapAsKey(YAML::Emitter& out, std::string& desiredOutput) void BlockMapAsKey(YAML::Emitter& out, std::string& desiredOutput)
@@ -255,7 +255,7 @@ namespace Test
out << "total value"; out << "total value";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\n?\n key: value\n next key: next value\n: total value"; desiredOutput = "?\n key: value\n next key: next value\n: total value";
} }
void AliasAndAnchor(YAML::Emitter& out, std::string& desiredOutput) void AliasAndAnchor(YAML::Emitter& out, std::string& desiredOutput)
@@ -269,7 +269,7 @@ namespace Test
out << YAML::Alias("fred"); out << YAML::Alias("fred");
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- &fred\n name: Fred\n age: 42\n- *fred"; desiredOutput = "- &fred\n name: Fred\n age: 42\n- *fred";
} }
void AliasAndAnchorWithNull(YAML::Emitter& out, std::string& desiredOutput) void AliasAndAnchorWithNull(YAML::Emitter& out, std::string& desiredOutput)
@@ -279,14 +279,14 @@ namespace Test
out << YAML::Alias("fred"); out << YAML::Alias("fred");
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- &fred ~\n- *fred"; desiredOutput = "- &fred ~\n- *fred";
} }
void SimpleVerbatimTag(YAML::Emitter& out, std::string& desiredOutput) void SimpleVerbatimTag(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << YAML::VerbatimTag("!foo") << "bar"; out << YAML::VerbatimTag("!foo") << "bar";
desiredOutput = "--- !<!foo> bar"; desiredOutput = "!<!foo> bar";
} }
void VerbatimTagInBlockSeq(YAML::Emitter& out, std::string& desiredOutput) void VerbatimTagInBlockSeq(YAML::Emitter& out, std::string& desiredOutput)
@@ -296,7 +296,7 @@ namespace Test
out << "baz"; out << "baz";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- !<!foo> bar\n- baz"; desiredOutput = "- !<!foo> bar\n- baz";
} }
void VerbatimTagInFlowSeq(YAML::Emitter& out, std::string& desiredOutput) void VerbatimTagInFlowSeq(YAML::Emitter& out, std::string& desiredOutput)
@@ -306,7 +306,7 @@ namespace Test
out << "baz"; out << "baz";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "--- [!<!foo> bar, baz]"; desiredOutput = "[!<!foo> bar, baz]";
} }
void VerbatimTagInFlowSeqWithNull(YAML::Emitter& out, std::string& desiredOutput) void VerbatimTagInFlowSeqWithNull(YAML::Emitter& out, std::string& desiredOutput)
@@ -316,7 +316,7 @@ namespace Test
out << "baz"; out << "baz";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "--- [!<!foo> ~, baz]"; desiredOutput = "[!<!foo> ~, baz]";
} }
void VerbatimTagInBlockMap(YAML::Emitter& out, std::string& desiredOutput) void VerbatimTagInBlockMap(YAML::Emitter& out, std::string& desiredOutput)
@@ -326,7 +326,7 @@ namespace Test
out << YAML::Value << YAML::VerbatimTag("!waz") << "baz"; out << YAML::Value << YAML::VerbatimTag("!waz") << "baz";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\n!<!foo> bar: !<!waz> baz"; desiredOutput = "!<!foo> bar: !<!waz> baz";
} }
void VerbatimTagInFlowMap(YAML::Emitter& out, std::string& desiredOutput) void VerbatimTagInFlowMap(YAML::Emitter& out, std::string& desiredOutput)
@@ -336,7 +336,7 @@ namespace Test
out << YAML::Value << "baz"; out << YAML::Value << "baz";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "--- {!<!foo> bar: baz}"; desiredOutput = "{!<!foo> bar: baz}";
} }
void VerbatimTagInFlowMapWithNull(YAML::Emitter& out, std::string& desiredOutput) void VerbatimTagInFlowMapWithNull(YAML::Emitter& out, std::string& desiredOutput)
@@ -346,21 +346,21 @@ namespace Test
out << YAML::Value << "baz"; out << YAML::Value << "baz";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "--- {!<!foo> ~: baz}"; desiredOutput = "{!<!foo> ~: baz}";
} }
void VerbatimTagWithEmptySeq(YAML::Emitter& out, std::string& desiredOutput) void VerbatimTagWithEmptySeq(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << YAML::VerbatimTag("!foo") << YAML::BeginSeq << YAML::EndSeq; out << YAML::VerbatimTag("!foo") << YAML::BeginSeq << YAML::EndSeq;
desiredOutput = "--- !<!foo>\n[]"; desiredOutput = "!<!foo>\n[]";
} }
void VerbatimTagWithEmptyMap(YAML::Emitter& out, std::string& desiredOutput) void VerbatimTagWithEmptyMap(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << YAML::VerbatimTag("!bar") << YAML::BeginMap << YAML::EndMap; out << YAML::VerbatimTag("!bar") << YAML::BeginMap << YAML::EndMap;
desiredOutput = "--- !<!bar>\n{}"; desiredOutput = "!<!bar>\n{}";
} }
void VerbatimTagWithEmptySeqAndMap(YAML::Emitter& out, std::string& desiredOutput) void VerbatimTagWithEmptySeqAndMap(YAML::Emitter& out, std::string& desiredOutput)
@@ -370,7 +370,7 @@ namespace Test
out << YAML::VerbatimTag("!bar") << YAML::BeginMap << YAML::EndMap; out << YAML::VerbatimTag("!bar") << YAML::BeginMap << YAML::EndMap;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- !<!foo>\n []\n- !<!bar>\n {}"; desiredOutput = "- !<!foo>\n []\n- !<!bar>\n {}";
} }
void ByKindTagWithScalar(YAML::Emitter& out, std::string& desiredOutput) void ByKindTagWithScalar(YAML::Emitter& out, std::string& desiredOutput)
@@ -381,14 +381,14 @@ namespace Test
out << YAML::TagByKind << "12"; out << YAML::TagByKind << "12";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- \"12\"\n- 12\n- ! 12"; desiredOutput = "- \"12\"\n- 12\n- ! 12";
} }
void LocalTagWithScalar(YAML::Emitter& out, std::string& desiredOutput) void LocalTagWithScalar(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << YAML::LocalTag("foo") << "bar"; out << YAML::LocalTag("foo") << "bar";
desiredOutput = "--- !foo bar"; desiredOutput = "!foo bar";
} }
void BadLocalTag(YAML::Emitter& out, std::string& desiredError) void BadLocalTag(YAML::Emitter& out, std::string& desiredError)
@@ -451,7 +451,7 @@ namespace Test
out << YAML::Value << YAML::Alias("id001"); out << YAML::Value << YAML::Alias("id001");
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\nreceipt: Oz-Ware Purchase Invoice\ndate: 2007-08-06\ncustomer:\n given: Dorothy\n family: Gale\nitems:\n - part_no: A4786\n descrip: Water Bucket (Filled)\n price: 1.47\n quantity: 4\n - part_no: E1628\n descrip: High Heeled \"Ruby\" Slippers\n price: 100.27\n quantity: 1\nbill-to: &id001\n street: |\n 123 Tornado Alley\n Suite 16\n city: East Westville\n state: KS\nship-to: *id001"; desiredOutput = "receipt: Oz-Ware Purchase Invoice\ndate: 2007-08-06\ncustomer:\n given: Dorothy\n family: Gale\nitems:\n - part_no: A4786\n descrip: Water Bucket (Filled)\n price: 1.47\n quantity: 4\n - part_no: E1628\n descrip: High Heeled \"Ruby\" Slippers\n price: 100.27\n quantity: 1\nbill-to: &id001\n street: |\n 123 Tornado Alley\n Suite 16\n city: East Westville\n state: KS\nship-to: *id001";
} }
void STLContainers(YAML::Emitter& out, std::string& desiredOutput) void STLContainers(YAML::Emitter& out, std::string& desiredOutput)
@@ -471,7 +471,7 @@ namespace Test
out << ages; out << ages;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- [2, 3, 5, 7, 11, 13]\n- Daniel: 26\n Jesse: 24"; desiredOutput = "- [2, 3, 5, 7, 11, 13]\n- Daniel: 26\n Jesse: 24";
} }
void SimpleComment(YAML::Emitter& out, std::string& desiredOutput) void SimpleComment(YAML::Emitter& out, std::string& desiredOutput)
@@ -481,7 +481,7 @@ namespace Test
out << YAML::Value << "least squares" << YAML::Comment("should we change this method?"); out << YAML::Value << "least squares" << YAML::Comment("should we change this method?");
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\nmethod: least squares # should we change this method?"; desiredOutput = "method: least squares # should we change this method?";
} }
void MultiLineComment(YAML::Emitter& out, std::string& desiredOutput) void MultiLineComment(YAML::Emitter& out, std::string& desiredOutput)
@@ -491,7 +491,7 @@ namespace Test
out << "item 2"; out << "item 2";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- item 1 # really really long\n # comment that couldn't possibly\n # fit on one line\n- item 2"; desiredOutput = "- item 1 # really really long\n # comment that couldn't possibly\n # fit on one line\n- item 2";
} }
void ComplexComments(YAML::Emitter& out, std::string& desiredOutput) void ComplexComments(YAML::Emitter& out, std::string& desiredOutput)
@@ -501,7 +501,7 @@ namespace Test
out << YAML::Value << "value"; out << YAML::Value << "value";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\n? long key # long key\n: value"; desiredOutput = "? long key # long key\n: value";
} }
void Indentation(YAML::Emitter& out, std::string& desiredOutput) void Indentation(YAML::Emitter& out, std::string& desiredOutput)
@@ -514,7 +514,7 @@ namespace Test
out << YAML::EndMap; out << YAML::EndMap;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- key 1: value 1\n key 2:\n - a\n - b\n - c"; desiredOutput = "- key 1: value 1\n key 2:\n - a\n - b\n - c";
} }
void SimpleGlobalSettings(YAML::Emitter& out, std::string& desiredOutput) void SimpleGlobalSettings(YAML::Emitter& out, std::string& desiredOutput)
@@ -529,7 +529,7 @@ namespace Test
out << YAML::EndMap; out << YAML::EndMap;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- ? key 1\n : value 1\n ? key 2\n : [a, b, c]"; desiredOutput = "- ? key 1\n : value 1\n ? key 2\n : [a, b, c]";
} }
void ComplexGlobalSettings(YAML::Emitter& out, std::string& desiredOutput) void ComplexGlobalSettings(YAML::Emitter& out, std::string& desiredOutput)
@@ -548,7 +548,7 @@ namespace Test
out << YAML::EndMap; out << YAML::EndMap;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- key 1: value 1\n key 2: [a, b, c]\n- ? [1, 2]\n :\n a: b"; desiredOutput = "- key 1: value 1\n key 2: [a, b, c]\n- ? [1, 2]\n :\n a: b";
} }
void Null(YAML::Emitter& out, std::string& desiredOutput) void Null(YAML::Emitter& out, std::string& desiredOutput)
@@ -561,26 +561,26 @@ namespace Test
out << YAML::EndMap; out << YAML::EndMap;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- ~\n- null value: ~\n ~: null key"; desiredOutput = "- ~\n- null value: ~\n ~: null key";
} }
void EscapedUnicode(YAML::Emitter& out, std::string& desiredOutput) void EscapedUnicode(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << YAML::EscapeNonAscii << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2"; out << YAML::EscapeNonAscii << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
desiredOutput = "--- \"$ \\xa2 \\u20ac \\U00024b62\""; desiredOutput = "\"$ \\xa2 \\u20ac \\U00024b62\"";
} }
void Unicode(YAML::Emitter& out, std::string& desiredOutput) void Unicode(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2"; out << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
desiredOutput = "--- \x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2"; desiredOutput = "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
} }
void DoubleQuotedUnicode(YAML::Emitter& out, std::string& desiredOutput) void DoubleQuotedUnicode(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << YAML::DoubleQuoted << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2"; out << YAML::DoubleQuoted << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
desiredOutput = "--- \"\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2\""; desiredOutput = "\"\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2\"";
} }
struct Foo { struct Foo {
@@ -606,7 +606,7 @@ namespace Test
out << Foo(3, "goodbye"); out << Foo(3, "goodbye");
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- x: 5\n bar: hello\n- x: 3\n bar: goodbye"; desiredOutput = "- x: 5\n bar: hello\n- x: 3\n bar: goodbye";
} }
void UserTypeInContainer(YAML::Emitter& out, std::string& desiredOutput) void UserTypeInContainer(YAML::Emitter& out, std::string& desiredOutput)
@@ -616,7 +616,7 @@ namespace Test
fv.push_back(Foo(3, "goodbye")); fv.push_back(Foo(3, "goodbye"));
out << fv; out << fv;
desiredOutput = "---\n- x: 5\n bar: hello\n- x: 3\n bar: goodbye"; desiredOutput = "- x: 5\n bar: hello\n- x: 3\n bar: goodbye";
} }
template <typename T> template <typename T>
@@ -637,7 +637,7 @@ namespace Test
out << bar << baz; out << bar << baz;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- 5\n- ~"; desiredOutput = "- 5\n- ~";
} }
void PointerToUserType(YAML::Emitter& out, std::string& desiredOutput) void PointerToUserType(YAML::Emitter& out, std::string& desiredOutput)
@@ -649,13 +649,13 @@ namespace Test
out << bar << baz; out << bar << baz;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- x: 5\n bar: hello\n- ~"; desiredOutput = "- x: 5\n bar: hello\n- ~";
} }
void NewlineAtEnd(YAML::Emitter& out, std::string& desiredOutput) void NewlineAtEnd(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << "Hello" << YAML::Newline << YAML::Newline; out << "Hello" << YAML::Newline << YAML::Newline;
desiredOutput = "--- Hello\n\n"; desiredOutput = "Hello\n\n";
} }
void NewlineInBlockSequence(YAML::Emitter& out, std::string& desiredOutput) void NewlineInBlockSequence(YAML::Emitter& out, std::string& desiredOutput)
@@ -663,7 +663,7 @@ namespace Test
out << YAML::BeginSeq; out << YAML::BeginSeq;
out << "a" << YAML::Newline << "b" << "c" << YAML::Newline << "d"; out << "a" << YAML::Newline << "b" << "c" << YAML::Newline << "d";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- a\n\n- b\n- c\n\n- d"; desiredOutput = "- a\n\n- b\n- c\n\n- d";
} }
void NewlineInFlowSequence(YAML::Emitter& out, std::string& desiredOutput) void NewlineInFlowSequence(YAML::Emitter& out, std::string& desiredOutput)
@@ -671,7 +671,7 @@ namespace Test
out << YAML::Flow << YAML::BeginSeq; out << YAML::Flow << YAML::BeginSeq;
out << "a" << YAML::Newline << "b" << "c" << YAML::Newline << "d"; out << "a" << YAML::Newline << "b" << "c" << YAML::Newline << "d";
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "--- [a\n, b, c\n, d]"; desiredOutput = "[a\n, b, c\n, d]";
} }
void NewlineInBlockMap(YAML::Emitter& out, std::string& desiredOutput) void NewlineInBlockMap(YAML::Emitter& out, std::string& desiredOutput)
@@ -681,7 +681,7 @@ namespace Test
out << YAML::Key << "b" << YAML::Newline << YAML::Value << "bar"; out << YAML::Key << "b" << YAML::Newline << YAML::Value << "bar";
out << YAML::LongKey << YAML::Key << "c" << YAML::Newline << YAML::Value << "car"; out << YAML::LongKey << YAML::Key << "c" << YAML::Newline << YAML::Value << "car";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\na: foo\n\nb: bar\n? c\n\n: car"; desiredOutput = "a: foo\n\nb: bar\n? c\n\n: car";
} }
void NewlineInFlowMap(YAML::Emitter& out, std::string& desiredOutput) void NewlineInFlowMap(YAML::Emitter& out, std::string& desiredOutput)
@@ -690,7 +690,7 @@ namespace Test
out << YAML::Key << "a" << YAML::Value << "foo" << YAML::Newline; out << YAML::Key << "a" << YAML::Value << "foo" << YAML::Newline;
out << YAML::Key << "b" << YAML::Newline << YAML::Value << "bar"; out << YAML::Key << "b" << YAML::Newline << YAML::Value << "bar";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "--- {a: foo\n, b\n: bar}"; desiredOutput = "{a: foo\n, b\n: bar}";
} }
void LotsOfNewlines(YAML::Emitter& out, std::string& desiredOutput) void LotsOfNewlines(YAML::Emitter& out, std::string& desiredOutput)
@@ -706,31 +706,31 @@ namespace Test
out << YAML::LongKey << YAML::Key << "f" << YAML::Newline << YAML::Value << "foo"; out << YAML::LongKey << YAML::Key << "f" << YAML::Newline << YAML::Value << "foo";
out << YAML::EndMap; out << YAML::EndMap;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = "---\n- a\n\n-\n - b\n - c\n\n\n-\n d: e\n ? f\n\n : foo"; desiredOutput = "- a\n\n-\n - b\n - c\n\n\n-\n d: e\n ? f\n\n : foo";
} }
void Binary(YAML::Emitter& out, std::string& desiredOutput) void Binary(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << YAML::Binary("Hello, World!", 13); out << YAML::Binary("Hello, World!", 13);
desiredOutput = "--- !!binary \"SGVsbG8sIFdvcmxkIQ==\""; desiredOutput = "!!binary \"SGVsbG8sIFdvcmxkIQ==\"";
} }
void LongBinary(YAML::Emitter& out, std::string& desiredOutput) void LongBinary(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << YAML::Binary("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n", 270); out << YAML::Binary("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n", 270);
desiredOutput = "--- !!binary \"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4K\""; desiredOutput = "!!binary \"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4K\"";
} }
void EmptyBinary(YAML::Emitter& out, std::string& desiredOutput) void EmptyBinary(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << YAML::Binary("", 0); out << YAML::Binary("", 0);
desiredOutput = "--- !!binary \"\""; desiredOutput = "!!binary \"\"";
} }
void ColonAtEndOfScalar(YAML::Emitter& out, std::string& desiredOutput) void ColonAtEndOfScalar(YAML::Emitter& out, std::string& desiredOutput)
{ {
out << "a:"; out << "a:";
desiredOutput = "--- \"a:\""; desiredOutput = "\"a:\"";
} }
void ColonAsScalar(YAML::Emitter& out, std::string& desiredOutput) void ColonAsScalar(YAML::Emitter& out, std::string& desiredOutput)
@@ -739,7 +739,7 @@ namespace Test
out << YAML::Key << "apple" << YAML::Value << ":"; out << YAML::Key << "apple" << YAML::Value << ":";
out << YAML::Key << "banana" << YAML::Value << ":"; out << YAML::Key << "banana" << YAML::Value << ":";
out << YAML::EndMap; out << YAML::EndMap;
desiredOutput = "---\napple: \":\"\nbanana: \":\""; desiredOutput = "apple: \":\"\nbanana: \":\"";
} }
void BoolFormatting(YAML::Emitter& out, std::string& desiredOutput) void BoolFormatting(YAML::Emitter& out, std::string& desiredOutput)
@@ -771,7 +771,7 @@ namespace Test
out << YAML::ShortBool << YAML::LowerCase << false; out << YAML::ShortBool << YAML::LowerCase << false;
out << YAML::EndSeq; out << YAML::EndSeq;
desiredOutput = desiredOutput =
"---\n- TRUE\n- True\n- true\n- FALSE\n- False\n- false\n" "- TRUE\n- True\n- true\n- FALSE\n- False\n- false\n"
"- YES\n- Yes\n- yes\n- NO\n- No\n- no\n" "- YES\n- Yes\n- yes\n- NO\n- No\n- no\n"
"- ON\n- On\n- on\n- OFF\n- Off\n- off\n" "- ON\n- On\n- on\n- OFF\n- Off\n- off\n"
"- Y\n- Y\n- y\n- N\n- N\n- n"; "- Y\n- Y\n- y\n- N\n- N\n- n";