Debian Codegraph @

t/02html02.t

raw
1 #! perl
2
3 use strict;
4 use warnings;
5 use Test::More qw(no_plan);
6
7 use Data::Report;
8
9 my $out = "";
10
11 my $rep = Data::Report::->create
12 (type => "html",
13 layout => [ { name => "acct", title => "Acct", width => 6 },
14 { name => "desc", title => "Report", width => 40, align => "|" },
15 { name => "deb", title => "Debet", width => 10, align => "<" },
16 { name => "crd", title => "Credit", width => 10, align => ">" },
17 ],
18 );
19
20 $rep->set_output(\$out);
21 $rep->start;
22 $rep->add({ acct => "one", desc => "two", deb => "three", crd => "four" });
23 $rep->add({ acct => "one", desc => "two", deb => "three", crd => "four", _style => "xyz" });
24 $rep->finish;
25 $rep->close;
26
27 my $ref; { undef $/; $ref = <DATA> }
28 $ref =~ s/[\r\n]/\n/g;
29 $out =~ s/[\r\n]/\n/g;
30
31 is($out, $ref);
32
33 __DATA__
34 <table class="main">
35 <tr class="head">
36 <th align="left" class="h_acct">Acct</th>
37 <th align="center" class="h_desc">Report</th>
38 <th align="left" class="h_deb">Debet</th>
39 <th align="right" class="h_crd">Credit</th>
40 </tr>
41 <tr>
42 <td align="left" class="c_acct">one</td>
43 <td align="center" class="c_desc">two</td>
44 <td align="left" class="c_deb">three</td>
45 <td align="right" class="c_crd">four</td>
46 </tr>
47 <tr class="r_xyz">
48 <td align="left" class="c_acct">one</td>
49 <td align="center" class="c_desc">two</td>
50 <td align="left" class="c_deb">three</td>
51 <td align="right" class="c_crd">four</td>
52 </tr>
53 </table>