import unit_threaded;
import std.conv;
// dfmt off
auto table= new AsciiTable(2)
.header.add("HA").add("HB")
.row.add("C").add("D")
.row.add("E").add("F")
.table;
auto f1 = table
.format
.parts(new UnicodeParts)
.borders(true)
.separators(true)
.to!string;
// dfmt on
std.stdio.writeln(f1);
f1.shouldEqual(`┌──┬──┐
│HA│HB│
╞══╪══╡
│C │D │
├──┼──┤
│E │F │
└──┴──┘`);
// dfmt off
auto f2 = table
.format
.parts(new UnicodeParts)
.prefix(" ")
.rowSeparator(true)
.to!string;
// dfmt on
f2.shouldEqual(` HAHB
─────
C D
─────
E F `);
// dfmt off
auto f3 = table
.format
.parts(new UnicodeParts)
.columnSeparator(true)
.to!string;
// dfmt on
f3.shouldEqual(`HA│HB
C │D
E │F `);
Example
import unit_threaded;
auto table= new AsciiTable(2).row.add("1\n2").add("3").row.add("4").add("5\n6").table;
auto f = table.format.prefix("test:").to!string;
f.shouldEqual(`test:13
test:2
test:45
test: 6`);
Example
import unit_threaded;
auto table= new AsciiTable(1).header.add("1").row.add(2).table;
auto f1 = table.format.headerSeparator(true).rowSeparator(true)
.topBorder(true).bottomBorder(true).to!string;
f1.shouldEqual(`-
1
=
2
-`);