6 use Test
::More tests
=> 13;
8 use DataExtract
::FixedWidth
;
10 my $file = File
::Spec
->catfile( 't', 'data', 'RusselAdams-Snap.txt' );
11 open ( my $fh, $file ) || die "Can not open $file";
14 my $fw = DataExtract
::FixedWidth
->new({ heuristic
=> \
@lines });
16 ok
( $fw->unpack_string eq 'a10a8a14a20a11A*'
17 , 'Testing hard coded prerendered unpack string got '
19 . ' expected "a10a8a14a20a11A*"'
22 foreach my $idx ( 0 .. $#lines ) {
23 my $line = $lines[$idx];
25 my $arrRef = $fw->parse( $line );
26 my $hashRef = $fw->parse_hash( $line );
30 ok
( $hashRef->{'PP RANGE'} eq '1-1', "Testing output (->parse_hash)" );
31 ok
( $hashRef->{'REGION'} eq 'outer edge', "Testing output (->parse_hash) got " . $hashRef->{'REGION'} );
32 ok
( $hashRef->{'MOUNT POINT'} eq 'N/A', "Testing output (->parse_hash) got " . $hashRef->{'MOUNT POINT'} );
34 ok
( $arrRef->[0] eq '1-1', "Testing output (->parse)" );
35 ok
( $arrRef->[2] eq 'outer edge', "Testing output (->parse)" );
36 ok
( $arrRef->[5] eq 'N/A', "Testing output (->parse)" );
39 ok
( $hashRef->{'PP RANGE'} eq '205-217', "Testing output (->parse_hash)" );
40 ok
( $hashRef->{'REGION'} eq 'outer middle', "Testing output (->parse_hash)" );
41 ok
( $hashRef->{'MOUNT POINT'} eq '', "Testing output (->parse_hash)" );
43 ok
( $arrRef->[0] eq '205-217', "Testing output (->parse)" );
44 ok
( $arrRef->[2] eq 'outer middle', "Testing output (->parse)" );
45 ok
( $arrRef->[5] eq '', "Testing output (->parse)" );