| 1 |
#! perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use Test::More qw(no_plan); |
| 6 |
|
| 7 |
use Data::Report; |
| 8 |
|
| 9 |
my $rep = Data::Report::->create(type => "text"); |
| 10 |
|
| 11 |
$rep->set_layout |
| 12 |
([ { name => "acct", title => "Acct", width => 6 }, |
| 13 |
{ name => "desc", title => "Report", width => 40, align => "|" }, |
| 14 |
{ name => "deb", title => "Debet", width => 10, align => "<" }, |
| 15 |
{ name => "crd", title => "Credit", width => 10, align => ">" }, |
| 16 |
]); |
| 17 |
|
| 18 |
my $out = ""; |
| 19 |
$rep->set_output(\$out); |
| 20 |
$rep->set_fields([qw(desc crd deb acct)]); |
| 21 |
$rep->set_width({ deb => 9, crd => '-1' }); |
| 22 |
$rep->start; |
| 23 |
$rep->add({ acct => "one", desc => "two", deb => "three", crd => "four" }); |
| 24 |
$rep->finish; |
| 25 |
$rep->close; |
| 26 |
|
| 27 |
my $ref; { undef $/; $ref = <DATA>; } |
| 28 |
$ref =~ s/[\r\n]/\n/g; |
| 29 |
|
| 30 |
is($out, $ref); |
| 31 |
|
| 32 |
__DATA__ |
| 33 |
Report Credit Debet Acct |
| 34 |
---------------------------------------------------------------------- |
| 35 |
two four three one |