=noris.netheads Name

table


=head1 Ziel

Testen des Tabellenkrams


=head1 Testfälle

So viele wie möglich ...

=cut


package Test::table;
use utf8;
use warnings;
use strict; use warnings;
BEGIN { unshift(@INC,($ENV{'POPHOME'}||'@POPHOME@').'/lib')
			unless $ENV{'KUNDE_NO_PERLPATH'};
      }

use Test::More tests => 6;
use Dbase::Test qw(okF okS okQ);

use noris::ASCIITable;
use noris::Table;
use IO::String;

my $outdata="";
my $outfile=IO::String->new($outdata);
sub out_start {
	no warnings 'once';
	$Db::test_output = $outfile;
	$outfile->setpos(0);
	$outdata="";
}

my $time=time;

my $t = noris::ASCIITable->new({ headingText => "Basket" });

$t->setCols("Id","Name","Price");
$t->addRow(1,"Dummy product 1",24.4);
$t->addRow(2,"Dummy product 2",21.2);
$t->addRow(3,"Dummy product 3",12.3);
$t->addRowLine();
$t->addRow("","Total",57.9);

is("$t",<<_,"alte Darstellung stimmt noch");
.------------------------------.
|            Basket            |
+----+-----------------+-------+
| Id | Name            | Price |
+----+-----------------+-------+
|  1 | Dummy product 1 |  24.4 |
|  2 | Dummy product 2 |  21.2 |
|  3 | Dummy product 3 |  12.3 |
+----+-----------------+-------+
|    | Total           |  57.9 |
'----+-----------------+-------'
_

my $da = ["+","+","-","+"];
my $db = ["","",""];
$t->{options}{headingText} = undef;
$t->{options}{headingStartChar} = "";
$t->{options}{headingStopChar} = "";
$t->{options}{hide_FirstLine} = 1;
$t->{options}{hide_HeadLine} = 1;
$t->{options}{hide_LastLine} = 1;
$t->{tbl_lines} = {};  ## delete addRowLine() effect

is($t->draw($da,$db,$da,$db,$da,$da),<<_,"neue Darstellung");
Id Name            Price
 1 Dummy product 1  24.4
 2 Dummy product 2  21.2
 3 Dummy product 3  12.3
   Total            57.9
_


out_start();
$t = noris::Table->new();
$t->titel("Id","Name","Price");
$t->daten(1,"Dummy product 1",24.4);
$t->daten(2,"Dummy product 2",21.2);
$t->daten(3,"Dummy product 3",12.3);
$t->drucken();
is($outdata,<<_,"Ausgabe mit ID");
Id Name            Price
 1 Dummy product 1  24.4
 2 Dummy product 2  21.2
 3 Dummy product 3  12.3
_


$t = noris::Table->new();
$t->skip(1);
$t->titel("Id","Name","Price");
$t->daten(1,"Dummy product 1",24.4);
$t->daten(2,"Dummy product 2",21.2);
$t->daten(3,"Dummy product 3",12.3);
out_start();
$t->drucken();
is($outdata,<<_,"Ausgabe ohne ID");
Name            Price
Dummy product 1  24.4
Dummy product 2  21.2
Dummy product 3  12.3
_

$t = noris::Table->new();
$t->titel("Id","Name","Price");
$t->daten(1,"Dummy product 1",24.4);
$t->daten(2,"Dummy product 2",21.2);
$t->skip(2);
$t->daten(3,"Dummy product 3",12.3);
out_start();
$t->drucken();
is($outdata,<<_,"Ausgabe ohne ID");
Id Price
 1  24.4
 2  21.2
 3  12.3
_


$t = noris::Table->new();
$t->skip(1);
$t->daten(1,"Dummy product 1",24.4);
$t->daten(2,"Dummy product 2",21.2);
$t->daten(3,"Dummy product 3",12.3);
out_start();
$t->drucken();
is($outdata,<<_,"Ausgabe ohne ID und ohne Titelzeile");
Dummy product 1 24.4
Dummy product 2 21.2
Dummy product 3 12.3
_


