summaryrefslogtreecommitdiff
path: root/t/04tables.t
blob: 5215be83bef0920a31776ae4bcbdfe807d2ac428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use Test::More tests => 5;

use_ok('Text::SimpleTable::AutoWidth');

my $t1 = Text::SimpleTable::AutoWidth->new();
$t1->row( 'Catalyst',          'rockz!' );
$t1->row( 'DBIx::Class',       'rockz!' );
$t1->row( 'Template::Toolkit', 'rockz!' );
is( $t1->draw, <<"EOF");
.-------------------+--------.
| Catalyst          | rockz! |
| DBIx::Class       | rockz! |
| Template::Toolkit | rockz! |
'-------------------+--------'
EOF

my $t2 = Text::SimpleTable::AutoWidth->new();
$t2->captions( [ 'ROCKZ!', 'Rockz!', 'rockz!' ] );
$t2->row( 'Catalyst', 'DBIx::Class', 'Template::Toolkit', 'HTML::Mason' );
is( $t2->draw, <<"EOF");
.----------+-------------+-------------------.
| ROCKZ!   | Rockz!      | rockz!            |
+----------+-------------+-------------------+
| Catalyst | DBIx::Class | Template::Toolkit |
'----------+-------------+-------------------'
EOF

my $t3 = Text::SimpleTable::AutoWidth->new( max_width => 9 );
$t3->row('Everything works!');
is( $t3->draw, <<"EOF");
.-------.
| Ever- |
| ythi- |
| ng w- |
| orks! |
'-------'
EOF

my $t4 = Text::SimpleTable::AutoWidth->new( fixed_width => 29 );
$t4->row('Everything works!');
is( $t4->draw, <<"EOF");
.---------------------------.
| Everything works!         |
'---------------------------'
EOF