X-Git-Url: http://git.rot13.org/?p=webpac2;a=blobdiff_plain;f=t%2F2-input-csv.t;h=845d1eeed86b05e299bc127c28e605601885e7af;hp=2ed084ec0622002ca8008404d745564dfe913674;hb=HEAD;hpb=e60b14a6092e1341c96d6d586b0d6968502b1dae diff --git a/t/2-input-csv.t b/t/2-input-csv.t index 2ed084e..845d1ee 100755 --- a/t/2-input-csv.t +++ b/t/2-input-csv.t @@ -3,7 +3,7 @@ use strict; use lib 'lib'; -use Test::More tests => 63; +use Test::More tests => 102; BEGIN { use_ok( 'WebPAC::Test' ); @@ -39,3 +39,20 @@ foreach my $mfn ( 1 ... $size ) { diag "rec: ", dump($rec), "\n" if $debug; } +ok(my $db = $input->open( + path => "$abs_path/data/header_first.csv", + header_first => 1, +), "open"); +ok(my $size = $input->size, "size"); +cmp_ok( $size, '==', 10 - 1, 'size header_first' ); + +foreach my $mfn ( 1 ... $size ) { + my $rec = $input->fetch; + ok($rec, "fetch $mfn"); + cmp_ok($rec->{'000'}->[0], '==', $mfn, 'has mfn'); + cmp_ok($input->pos, '==', $mfn, "pos $mfn"); + + cmp_ok( $rec->{'A'}, 'eq', $rec->{'publication_title'}, 'A eq publication_title' ); + diag "rec: ", dump($rec), "\n" if $debug; +} +