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
|
#!/usr/bin/env perl
# Test use of widths
use Data::ShowTable;
require 'Test-Setup.pl';
sub start_tests($);
sub run_test($&);
$showSub = \&ShowBoxTable unless $showSub ne '';
start_tests 8;
# Test negative widths
run_test 1, sub {
&$showSub({ widths => [ -5, -20, -10, -30, -10 ],
titles => \@Titles,
types => \@Types,
row_sub => \&showDataRow,
});
};
# Test positive widths
run_test 2, sub {
&$showSub({ widths => [ +5, +20, +10, +30, +10 ],
titles => \@Titles,
types => \@Types,
row_sub => \&showDataRow,
});
};
# Test 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 => [ +15, +30, +20, +40, +15 ],
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 => [ +15, +30, +20, +40, +15 ],
titles => \@Titles,
types => \@Types,
row_sub => \&showDataRowOnce,
});
};
# Still have fixed columns, but maybe cause wrapping
run_test 6, sub {
&$showSub({ widths => [ +14, +25, +15, +25, +10 ],
titles => \@Titles,
types => \@Types,
row_sub => \&showDataRowOnce,
});
};
# Now, have a no-limit column mixed in with a fixed width
run_test 7, sub {
&$showSub({ widths => [ +14, 0, +15, +25, +10 ],
titles => \@Titles,
types => \@Types,
row_sub => \&showDataRow
});
};
# Now, have a no-limit column mixed in with a max width
run_test 8, sub {
&$showSub({ widths => [ +14, '', +10, +10, +10 ],
titles => \@Titles,
types => \@Types,
row_sub => \&showDataRow
});
};
|