@@ -26,7 +26,19 @@ my $importer = $pkg->new(file => \$csv);
26
26
27
27
isa_ok $importer , $pkg ;
28
28
29
- is_deeply $importer -> to_array, $data ;
29
+ is_deeply $importer -> to_array, $data , ' CSV with header.' ;
30
+
31
+ $csv = <<EOF ;
32
+ \xEF\xBB\xBF "name","age"
33
+ "Patrick","39"
34
+ "Nicolas","34"
35
+ EOF
36
+
37
+ $importer = $pkg -> new(file => \$csv );
38
+
39
+ isa_ok $importer , $pkg ;
40
+
41
+ is_deeply $importer -> to_array, $data , ' CSV with header, BOM.' ;
30
42
31
43
$data = [{0 => ' Patrick' , 1 => ' 39' }, {0 => ' Nicolas' , 1 => ' 34' },];
32
44
37
49
38
50
$importer = $pkg -> new(file => \$csv , header => 0);
39
51
40
- is_deeply $importer -> to_array, $data ;
52
+ is_deeply $importer -> to_array, $data , ' CSV without header. ' ;
41
53
42
54
$data = [{name => ' Nicolas' , age => ' 34' },];
43
55
48
60
49
61
$importer = $pkg -> new(file => \$csv , sep_char => ' \t' );
50
62
51
- is_deeply $importer -> to_array, $data ;
63
+ is_deeply $importer -> to_array, $data , ' CSV with header, separator is tab.' ;
64
+
65
+ $csv = <<EOF ;
66
+ \xEF\xBB\xBF "name" "age"
67
+ "Nicolas" "34"
68
+ EOF
69
+
70
+ $importer = $pkg -> new(file => \$csv , sep_char => ' \t' );
71
+
72
+ is_deeply $importer -> to_array, $data , ' CSV with header, separator is tab, BOM.' ;
52
73
53
74
done_testing;
54
75
0 commit comments