Revision 8fba112b
Von Sven Schöling vor mehr als 13 Jahren hinzugefügt
t/helper/csv.t | ||
---|---|---|
6 | 6 |
my $csv; |
7 | 7 |
|
8 | 8 |
$csv = SL::Helper::Csv->new( |
9 |
file => \"Kaffee;\n",
|
|
9 |
file => \"Kaffee\n", |
|
10 | 10 |
header => [ 'description' ], |
11 | 11 |
); |
12 | 12 |
|
... | ... | |
111 | 111 |
); |
112 | 112 |
is $csv->parse, undef, 'broken csv header won\'t get parsed'; |
113 | 113 |
|
114 |
###### |
|
115 |
|
|
116 |
$csv = SL::Helper::Csv->new( |
|
117 |
file => \<<EOL, |
|
118 |
description;partnumber;sellprice;lastcost_as_number; |
|
119 |
"Kaf"fee";;0.12;1,221.52 |
|
120 |
Beer;1123245;0.12;1.5234 |
|
121 |
EOL |
|
122 |
numberformat => '1,000.00', |
|
123 |
class => 'SL::DB::Part', |
|
124 |
); |
|
125 |
is $csv->parse, undef, 'broken csv content won\'t get parsed'; |
|
126 |
is_deeply $csv->errors, [ '"Kaf"fee";;0.12;1,221.52'."\n", 2023, 'EIQ - QUO character not allowed', 5, 2 ], 'error'; |
|
114 | 127 |
|
115 | 128 |
done_testing(); |
116 | 129 |
# vim: ft=perl |
Auch abrufbar als: Unified diff
CSV: Errorhandling
Parser umgeschrieben, eof muss nach getline prüfen (bekloppt).
Errorhandling aktiviert. Dokumentation aktualisiert.