X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=xt%2Fauthor%2FText_CSV_Various.t;h=f7f8ff966e0636410fa1c5bdd8d2763ac429259a;hb=36a52382227aecca98f8b57314d4374a60a99227;hp=a01f1584f50e3eca9bf73dba35fc25cc95a56250;hpb=da13a339bb2d6f882d6f4e6e323ab00c6c1d6419;p=koha.git diff --git a/xt/author/Text_CSV_Various.t b/xt/author/Text_CSV_Various.t index a01f1584f5..f7f8ff966e 100755 --- a/xt/author/Text_CSV_Various.t +++ b/xt/author/Text_CSV_Various.t @@ -1,17 +1,30 @@ #!/usr/bin/perl -use strict; -use warnings; +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, see . -use Test::More tests => 25; -BEGIN { - diag " -This test demonstrates why Koha uses the CSV parser and configration it does. -Specifically, the test is for Unicode compliance in text parsing and data. -This test requires other modules that Koha doesn't actually use, in order to compare. -Therefore, running this test is not necessary to test your Koha installation. +#This test demonstrates why Koha uses the CSV parser and configration +#it does. Specifically, the test is for Unicode compliance in text +#parsing and data. This test requires other modules that Koha doesn't +#actually use, in order to compare. Therefore, running this test is not +#necessary to test your Koha installation. + +use Modern::Perl; -"; +use Test::More tests => 32; +use Test::Warn; +BEGIN { use FindBin; use lib $FindBin::Bin; use_ok('Text::CSV'); @@ -42,7 +55,9 @@ my $lines = [ ]; # 010D: č LATIN SMALL LETTER C WITH CARON # 0117: ė LATIN SMALL LETTER E WITH DOT ABOVE -diag sprintf "Testing %d lines with %d parsers.", scalar(@$lines), scalar(keys %parsers); +ok( scalar(keys %parsers)>0 && scalar(@$lines)>0, + sprintf "Testing %d lines with %d parsers.", + scalar(@$lines), scalar(keys %parsers) ); foreach my $key (sort keys %parsers) { my $parser = $parsers{$key}; print "Testing parser $key version " . ($parser->version||'?') . "\n"; @@ -54,15 +69,31 @@ LINE: foreach (@$lines) { foreach my $key (sort keys %parsers) { my $parser = $parsers{$key}; my ($status,$count,@fields); - ok($status = $parser->parse($_->{line}), "parse ($key)"); + $status = $parser->parse($_->{line}); if ($status) { + ok($status, "parse ($key)"); @fields = $parser->fields; ok(($count = scalar(@fields)) == 6, "Number of fields ($count of 6)"); my $j = 0; foreach my $f (@fields) { - print "\t field " . ++$j . ": $f\n"; + ++$j; + if ($j==4) { + if ($key ne 'Text::CSV::Unicode (binary)') { + warning_like { + print "\t field " . $j . ": $f\n" + } [ qr/Wide character in print/ ], 'Expected wide print'; + } else { + print "\t field " . $j . ": $f\n" + } + } + else { + print "\t field " . $j . ": $f\n"; + } } } + else { + ok(! $status, "parse ($key) fails as expected"); + } } } -diag "done.\n"; +done_testing();