File: 04tables.t

package info (click to toggle)
libtext-simpletable-perl 1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 80 kB
  • ctags: 7
  • sloc: perl: 297; makefile: 15
file content (95 lines) | stat: -rw-r--r-- 1,722 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!perl

# Copyright (C) 2005-2009, Sebastian Riedel.

use strict;
use warnings;

use Test::More tests => 6;

use_ok('Text::SimpleTable');

# No titles and multiple rows
my $t1 = Text::SimpleTable->new(5, 10);
$t1->row('Catalyst',          'rockz!');
$t1->row('DBIx::Class',       'suckz!');
$t1->row('Template::Toolkit', 'rockz!');
is($t1->draw, <<EOF);
.-------+------------.
| Cata- | rockz!     |
| lyst  |            |
| DBIx- | suckz!     |
| ::Cl- |            |
| ass   |            |
| Temp- | rockz!     |
| late- |            |
| ::To- |            |
| olkit |            |
'-------+------------'
EOF

# Titles and multiple cols
my $t2 = Text::SimpleTable->new([5, 'ROCKZ!'], [10, 'Suckz!'], [7, 'rockz!']);
$t2->row('Catalyst', 'DBIx::Class', 'Template::Toolkit', 'HTML::Mason');
is($t2->draw, <<EOF);
.-------+------------+---------.
| ROCK- | Suckz!     | rockz!  |
| Z!    |            |         |
+-------+------------+---------+
| Cata- | DBIx::Cla- | Templa- |
| lyst  | ss         | te::To- |
|       |            | olkit   |
'-------+------------+---------'
EOF

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

# Horizontal rule
my $t4 = Text::SimpleTable->new(5);
$t4->row('Everything works!');
$t4->hr;
$t4->row('Everything works!');
is($t4->draw, <<EOF);
.-------.
| Ever- |
| ythi- |
| ng w- |
| orks! |
+-------+
| Ever- |
| ythi- |
| ng w- |
| orks! |
'-------'
EOF

# Bad width
my $t5 = Text::SimpleTable->new(1);
$t5->row('Works!');
$t5->hr;
$t5->row('Works!');
is($t5->draw, <<EOF);
.----.
| W- |
| o- |
| r- |
| k- |
| s! |
+----+
| W- |
| o- |
| r- |
| k- |
| s! |
'----'
EOF