fix windows/mac linebreaks
This commit is contained in:
parent
1448c8fe86
commit
d4ed861920
|
@ -319,3 +319,28 @@ struct Dumper(Range)
|
||||||
//account for newline at end
|
//account for newline at end
|
||||||
assert(stream.data[$-4..$-1] != "...");
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ string lineBreak(in LineBreak b) pure @safe nothrow
|
||||||
final switch(b)
|
final switch(b)
|
||||||
{
|
{
|
||||||
case LineBreak.Unix: return "\n";
|
case LineBreak.Unix: return "\n";
|
||||||
case LineBreak.Windows: return "\r";
|
case LineBreak.Windows: return "\r\n";
|
||||||
case LineBreak.Macintosh: return "\r\n";
|
case LineBreak.Macintosh: return "\r";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue