--- loncom/xml/lontable.test 2008/12/09 11:50:08 1.2 +++ loncom/xml/lontable.test 2008/12/29 11:57:37 1.4 @@ -3,7 +3,7 @@ # The LearningOnline Network with CAPA # Generating TeX tables. # -# $Id: lontable.test,v 1.2 2008/12/09 11:50:08 foxr Exp $ +# $Id: lontable.test,v 1.4 2008/12/29 11:57:37 foxr Exp $ # # # Copyright Michigan State University Board of Trustees @@ -219,30 +219,35 @@ ok($cell->{'colspan'} == 1, 'Colspan 2,2 # +----------+---------+----+-----------+---------+ -$testobject = new Apache::lontable(); +$testobject = new Apache::lontable({theme => "Dresden", + caption => "This is the table caption", + outer_border => 1, + inner_border => 1, + width => '1.0\textwidth', + alignment => 'left'}); $testobject->start_row(); $testobject->add_cell('2 cols 3 rows', {rowspan => 3, colspan => 2}); $testobject->add_cell('2 cols 1 row', {colspan => 2}); $testobject->end_row(); -$testobject->start_row(); -$testobject->add_cell('ordinary cell'); +$testobject->start_row({default_halign => 'left'}); $testobject->add_cell('ordinary cell'); +$testobject->add_cell('ordinary cell', {halign => 'center'}); $testobject->end_row(); -$testobject->start_row(); -$testobject->add_cell('2 rows 1 col', {rowspan => 2}); +$testobject->start_row({default_halign => 'right'}); +$testobject->add_cell('2 rows 1 col', {rowspan => 2, halign => 'right'}); $testobject->add_cell('ordinary cell'); $testobject->end_row(); -$testobject->start_row(); -$testobject->add_cell('ordinary cell'); +$testobject->start_row({default_halign => 'center'}); $testobject->add_cell('ordinary cell'); $testobject->add_cell('ordinary cell'); +$testobject->add_cell('ordinary cell', {halign => 'left'}); $testobject->end_row(); -# First of all the table should have figured out tere are 4 cols and 4 rows: +# First of all the table should have figured out there are 4 cols and 4 rows: ok($testobject->get_object_attribute('column_count') == 4, 'col count with spans'); @@ -264,6 +269,7 @@ ok($cells->[1]->{'contents'} eq '2 cols $row = $testobject->get_row(1); $cells = $row->{'cells'}; + ok(scalar(@$cells) == 3, ' 3 cell hashes in row 1'); ok($cells->[0]->{'rowspan'} == 2, '2,1 rowspan carried from above'); ok($cells->[0]->{'colspan'} == 2, '2,1 colspan carried from above'); @@ -305,6 +311,7 @@ ok($cells->[0]->{'contents'} eq 'ordinar ok($cells->[1]->{'rowspan'} == 1, '4,2 rowspan'); ok($cells->[1]->{'colspan'} == 1, '4,2 colspan'); +my $contents = $cells->[1]->{'contents'}; ok($cells->[1]->{'contents'} eq 'ordinary cell', '4,2, contents'); ok($cells->[2]->{'rowspan'} == 1, "4,3 rowspan carried down"); @@ -312,5 +319,14 @@ ok($cells->[2]->{'colspan'} == 1, '4,3 c ok($cells->[2]->{'contents'} eq '', '4,3 contents empty'); ok($cells->[3]->{'rowspan'} == 1, "4,4 rowspan"); -ok($cells->[3]->{'colspan'} == 2, '4,4 colspan'); +ok($cells->[3]->{'colspan'} == 1, '4,4 colspan'); ok($cells->[3]->{'contents'} eq 'ordinary cell', '4,4 contents'); + + + +my $table = $testobject->generate(); +$table->set_filename('table.tex'); +$table->generate(); + + +