File: 13.t

package info (click to toggle)
libtext-tabulardisplay-perl 1.38-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 200 kB
  • sloc: perl: 766; makefile: 2
file content (60 lines) | stat: -rwxr-xr-x 1,343 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl
# vim: set ft=perl:

# Following a bug report from David N. Blank-Edelman <dnb@ccs.neu.edu>,
# I have added this test to check for silliness in how columns behaves.
# Regardless of how many times columns gets called, there should only be
# one element in $t->{ _COLUMNS }.

use strict;
use Text::TabularDisplay;
use Test;

BEGIN {
    plan tests => 14;
}


my $t;

$t = Text::TabularDisplay->new;
$t->columns(qw{hi there});
ok(scalar @{$t->{ _COLUMNS }}, 1);
ok(scalar $t->columns, 2);

$t->columns(qw{hi there folks});
ok(scalar @{$t->{ _COLUMNS }}, 1);
ok(scalar $t->columns, 3);

ok($t->reset);
ok($t->add(qw[1 2 3]));
ok($t->add(qw[4 5 6]));
ok($t->render, "+---+---+---+
| 1 | 2 | 3 |
| 4 | 5 | 6 |
+---+---+---+");

ok($t->columns(qw[one two three]));
ok($t->render, "+-----+-----+-------+
| one | two | three |
+-----+-----+-------+
| 1   | 2   | 3     |
| 4   | 5   | 6     |
+-----+-----+-------+");

ok($t->columns(qw[one two]));
ok($t->render, "+-----+-----+-------+
| one | two |       |
+-----+-----+-------+
| 1   | 2   | 3     |
| 4   | 5   | 6     |
+-----+-----+-------+");

ok($t->columns(qw[one two three four]));
ok($t->render, "+-----+-----+-------+------+
| one | two | three | four |
+-----+-----+-------+------+
| 1   | 2   | 3     |      |
| 4   | 5   | 6     |      |
+-----+-----+-------+------+");