fixed manifest with tests
[DataExtract-FixedWidth.git] / t / 04-Fix-Overlay.t
blob10c397da1e73760e78c0df07df91abf87c7c7e89
1 #!/usr/bin/env perl
2 ## Quick test for fix_overlay
3 use strict;
4 use warnings;
5 use feature ':5.10';
7 use Test::More tests => 3;
8 use File::Spec;
9 use DataExtract::FixedWidth;
11 my $file = File::Spec->catfile( 't', 'data', 'Fix-Overlay.txt' );
12 open ( my $fh, $file ) || die "Can not open $file";
14 while ( my $line = <$fh> ) {
15 state $fw;
17 if ( $. == 1 ) {
18 $fw = DataExtract::FixedWidth->new({
19 header_row => $line
20 , fix_overlay => 1
21 });
23 else {
24 my $arrRef = $fw->parse( $line );
25 my $hashRef = $fw->parse_hash( $line );
27 given ( $. ) {
28 when ( 2 ) {
29 ok ( $hashRef->{id} eq 1, "Testing output (->parse_hash)" );
30 ok ( $hashRef->{name} eq 'Amy is foobared', "Testing output (->parse_hash)" );
31 ok ( $hashRef->{team} eq 'She likes the bulls.', "Testing output (->parse_hash)" );