File: wrap.pl

package info (click to toggle)
libdata-showtable-perl 4.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,032 kB
  • sloc: perl: 2,221; sh: 38; makefile: 7
file content (75 lines) | stat: -rwxr-xr-x 1,769 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env perl

# Test use of wrapping

use Data::ShowTable;
require 'Test-Setup.pl';

sub start_tests($);
sub run_test($&);

$showSub = \&ShowBoxTable unless $showSub ne '';

@Data = ( [ "Alan", "This is a very long line of text which simulates a text ".
		    "string which is supposed to wrap in its field width." ],
	  [ "Kevin", "This is another long line of text which will also wrap ".
		    "so I can see if this part of ShowTable really works as ".
		    "designed.  If not it's back to the drawing board." ],
	  [ "Toad",  "This is a short line" ],
	  [ "Monica", "This is another short line" ],
	  [ "Stu",   "Finally, here is another long line which shold wrap but ".
		    "maybe not" ],
	);
@Types  = qw( char text );
@Titles = qw( Name Biography );

start_tests 5;

# Test negative widths
run_test 1, sub {
    &$showSub({	widths	=> [ -10, 40 ],
		titles  => \@Titles,
		types   => \@Types, 
		row_sub => \&showDataRow,
	      });
};

# Test with positive widths
run_test 2, sub {
    &$showSub({	widths	=> [ 10, 40 ],
		titles  => \@Titles,
		types   => \@Types, 
		row_sub => \&showDataRow,
	      });
};

# Test with no widths
run_test 3, sub {
    &$showSub({ widths  => [ ],
		titles  => \@Titles,
		types   => \@Types, 
		row_sub => \&showDataRow,
	  });
};

# Test large widths (with a rewindable data set, should be the same as
# minimal columns).
run_test 4, sub {
    &$showSub({ widths  => [ 20, 60 ],
		titles  => \@Titles,
		types   => \@Types, 
		row_sub => \&showDataRow,
	  });
};

# Test large widths with non-rewindable data set. (can't analyze the
# data, so columns will be large).

run_test 5, sub {
    &$showSub({ widths  => [ 20, 60 ],
		titles  => \@Titles,
		types   => \@Types, 
		row_sub => \&showDataRowOnce,
	  });
};