Merge pull request #129 from Herringway/doc-markers-test

add tests for explicit doc markers
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
This commit is contained in:
The Dlang Bot 2018-04-30 11:59:07 +02:00 committed by GitHub
commit f4f16666cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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] != "...");
}