From fa432a309f5c1c8e25abbc3ebe595c07bfa816b6 Mon Sep 17 00:00:00 2001 From: Cameron Ross Date: Sun, 29 Apr 2018 18:30:43 -0300 Subject: [PATCH] add tests for explicit doc markers --- source/dyaml/dumper.d | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/source/dyaml/dumper.d b/source/dyaml/dumper.d index 3935018..48af1d3 100644 --- a/source/dyaml/dumper.d +++ b/source/dyaml/dumper.d @@ -350,3 +350,35 @@ struct Dumper dumper.resolver = resolver; dumper.dump(node); } +// Explicit document start/end markers +@safe unittest +{ + import dyaml.stream; + auto stream = new YMemoryStream(); + auto node = Node([1, 2, 3, 4, 5]); + auto dumper = Dumper(stream); + dumper.explicitEnd = true; + dumper.explicitStart = true; + dumper.YAMLVersion = null; + dumper.dump(node); + //Skip version string + assert(stream.data[0..3] == "---"); + //account for newline at end + assert(stream.data[$-4..$-1] == "..."); +} +// No explicit document start/end markers +@safe unittest +{ + import dyaml.stream; + auto stream = new YMemoryStream(); + auto node = Node([1, 2, 3, 4, 5]); + auto dumper = Dumper(stream); + dumper.explicitEnd = false; + dumper.explicitStart = false; + dumper.YAMLVersion = null; + dumper.dump(node); + //Skip version string + assert(stream.data[0..3] != "---"); + //account for newline at end + assert(stream.data[$-4..$-1] != "..."); +}