head 1.1; access; symbols; locks; strict; comment @# @; 1.1 date 2005.05.09.20.24.09; author nwiger; state Exp; branches; next ; desc @tests @ 1.1 log @Initial revision @ text @#!/usr/bin/perl -I. -w # Copyright (c) 2001-2005 Nathan Wiger # simple tests for HTML::QuickTable use strict; use Test; BEGIN { plan tests => 8 }; use HTML::QuickTable; my @@tests = ( { new => { font => 'arial', }, dat => [ [ 1..4 ], [6..9] ], res => '
1 2 3 4
6 7 8 9
', }, { new => { font => 'arial', font_size => '+3', td => { class => 'myClass' }, th => { class => 'heading', bgcolor => 'gray' }, table => { width => '100%' }, labels => 1, }, dat => [ [qw/one two three four/], [qw/five six seven eight/], [qw/nine ten eleven twelve/] ], res => '
one two three four
five six seven eight
nine ten eleven twelve
', }, { new => { table_width => '95%', border => 0, table_cellpadding => '3', table_cellspacing => '5', lalign => 'right', labels => 1, }, # can only test hash pairs, since anything else may be reordered! dat => [ {qw/one two/}, {qw/five six/}, {qw/nine ten/} ], res => '
one
two
five
six
nine
ten
', }, { new => { labels => 'L', vertical => 1, table_width => '99%', header => 1, body => {text => 'red', bgcolor => 'black'}, }, dat => [ ['User', 'Name', 'Ext', 'Email'], [ 'nwiger', 'Nathan Wiger', 'x43264', 'nate@@wiger.org' ], [ 'jbobson', 'Jim Bobson', 'x92811', 'jim@@bobson.com' ], ], res => 'Content-type: text/html; charset=iso-8859-1
User nwiger jbobson
Name Nathan Wiger Jim Bobson
Ext x43264 x92811
Email nate@@wiger.org jim@@bobson.com
', }, { new => { htmlize => 1, title => 'Tacos for everyone', null => 'N/A', nulltags => {bgcolor => 'gray'}, header => 1, text => 'Hey there!', vertical => 1, labels => 'R', }, dat => [ ['User', 'Name', 'Ext', 'Email'], [ 'nwiger', 'Nathan Wiger', undef, 'nate@@wiger.org' ], [ 'jbobson', undef, 'x92811', 'jim@@bobson.com' ], ], res => 'Content-type: text/html; charset=iso-8859-1 Tacos for everyone

Tacos for everyone

Hey there!
User nwiger jbobson
Name Nathan Wiger N/A
Ext N/A x92811
Email nate@@wiger.org jim@@bobson.com
', }, { new => { font => 'should be missing', stylesheet => '/path/to/style.css', styleclass => 'yo.momma', td => {class => 'overridden'}, th => {class => 'killed'}, tr => {class => 'bleearged'}, labels => 1, header => 1, title => 'Test Results??>', body_BGCOLOR => 'blah', }, dat => [ ['n1','n2','n3','n4'], [ 1..4 ], [6..9] ], res => 'Content-type: text/html; charset=iso-8859-1 Test Results??>

Test Results??>

n1 n2 n3 n4
1 2 3 4
6 7 8 9
', }, { new => { useid => 'results', #stylesheet => '/path/to/style.css', #styleclass => 'yo', labels => 1, }, dat => [ ['n1','n2','n3','n4'], [ 1..4 ], [6..9] ], res => '
n1 n2 n3 n4
1 2 3 4
6 7 8 9
', }, { new => { stylesheet => 1, styleclass => ['one', 'two', 'four'], nulltags => {class => 'null'}, null => 'NULL', }, dat => [ ['n1','n2',undef,'n4'], [ 1..4 ], [6..9], [10,undef,12,13], ['a'..'d'] ], res => '
n1 n2 NULL n4
1 2 3 4
6 7 8 9
10 NULL 12 13
a b c d
', }, ); for (@@tests) { my $qt = HTML::QuickTable->new(%{$_->{new}}); my $qtr = $qt->render($_->{dat}); my $res = ok($qtr, $_->{res}); if (!$res && $ENV{LOGNAME} eq 'nwiger') { open(O, ">/tmp/qt.1"); print O $_->{res}; close O; open(O, ">/tmp/qt.2"); print O $qtr; close O; system "diff /tmp/qt.?"; system "rm -f /tmp/qt.?"; exit $res; } } @