force utf-8 encoding on all data comming from file
[webpac2] / t / 2-input-csv.t
index 096a207..2ed084e 100755 (executable)
@@ -1,13 +1,15 @@
 #!/usr/bin/perl -w
 
 use strict;
-use blib;
+use lib 'lib';
 
-use Test::More tests => 27;
+use Test::More tests => 63;
 
 BEGIN {
 use_ok( 'WebPAC::Test' );
 use_ok( 'WebPAC::Input' );
+use_ok( 'Encode' );
+use_ok( 'Devel::Peek' );
 }
 
 my $module = 'WebPAC::Input::CSV';
@@ -23,13 +25,17 @@ ok(my $db = $input->open(
        path => "$abs_path/data/records-utf8.csv"
 ), "open");
 ok(my $size = $input->size, "size");
-cmp_ok( $size, '==', 7, 'size ok' );
+cmp_ok( $size, '==', 11, 'size ok' );
 
 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");
+
+       ok( my $txt = $rec->{'E'}, 'E' );
+       diag Dump( $txt ) if $debug;
+       ok( Encode::is_utf8( $txt, 1 ), 'utf8' );
        diag "rec: ", dump($rec), "\n" if $debug;
 }