Merge pull request #188 from Herringway/linebreak-tests

fix windows/mac linebreaks
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
This commit is contained in:
The Dlang Bot 2018-07-31 20:30:49 +02:00 committed by GitHub
commit 206995836d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 2 deletions

View file

@ -319,3 +319,28 @@ struct Dumper(Range)
//account for newline at end
assert(stream.data[$-4..$-1] != "...");
}
// Windows, macOS line breaks
@safe unittest
{
auto node = Node(0);
{
auto stream = new Appender!string();
auto dumper = dumper(stream);
dumper.explicitEnd = true;
dumper.explicitStart = true;
dumper.YAMLVersion = null;
dumper.lineBreak = LineBreak.Windows;
dumper.dump(node);
assert(stream.data == "--- 0\r\n...\r\n");
}
{
auto stream = new Appender!string();
auto dumper = dumper(stream);
dumper.explicitEnd = true;
dumper.explicitStart = true;
dumper.YAMLVersion = null;
dumper.lineBreak = LineBreak.Macintosh;
dumper.dump(node);
assert(stream.data == "--- 0\r...\r");
}
}

View file

@ -26,7 +26,7 @@ string lineBreak(in LineBreak b) pure @safe nothrow
final switch(b)
{
case LineBreak.Unix: return "\n";
case LineBreak.Windows: return "\r";
case LineBreak.Macintosh: return "\r\n";
case LineBreak.Windows: return "\r\n";
case LineBreak.Macintosh: return "\r";
}
}