style
[DataExtract-FixedWidth.git] / t / 05-BrowserUK.t
blobcd940334e881a18021a59caee339eb7c0c7c72fd
1 #!/usr/bin/env perl
2 ## All code shameless ripped, with slight modifications
3 ## from BrowserUK's pm post http://perlmonks.org/?node_id=628059
4 use strict;
5 use warnings;
6 use feature ':5.10';
8 use Test::More tests => 5;
9 use File::Spec;
10 use DataExtract::FixedWidth;
12 my $file = File::Spec->catfile( 't', 'data', 'BrowserUK.txt' );
13 open ( my $fh, $file ) || die "Can not open $file";
15 my @lines = <$fh>;
16 my $de = DataExtract::FixedWidth->new({ heuristic => \@lines });
18 foreach my $lineidx ( 1 .. @lines ) {
19 my $line = $lines[$lineidx];
20 my $arr = $de->parse( $line );
22 given ( $lineidx ) {
23 when ( 1 ) {
24 ok( $arr->[0] cmp 'The First One Here Is Longer.', "Testing response (parse)" );
25 ok( $arr->[5] cmp 'MVP', "Testing response (parse)" );
26 ok( $arr->[4] cmp '93871', "Testing response (parse)" );
28 when ( 5 ) {
29 ok( $arr->[1] cmp 'Twin 200 SH', "Testing response (parse)" );
30 ok( $arr->[5] cmp 'VRE', "Testing response (parse)" );