add tests for explicit doc markers

This commit is contained in:
Cameron Ross 2018-04-29 18:30:43 -03:00
parent aa1af974e8
commit fa432a309f
No known key found for this signature in database
GPG key ID: 777897D98DC91C54

View file

@ -350,3 +350,35 @@ struct Dumper
dumper.resolver = resolver; dumper.resolver = resolver;
dumper.dump(node); 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] != "...");
}