1# Before `make install' is performed this script should be runnable with
2# `make test'. After `make install' it should work as `perl test.pl'
3
4######################### We start with some black magic to print on failure.
5
6# Change 1..1 below to 1..last_test_to_print .
7# (It may become useful if the test is moved to ./t subdirectory.)
8
9BEGIN { $| = 1; print "1..7\n"; }
10END {print "not ok 1\n" unless $loaded;}
11use Parse::FixedLength;
12$loaded = 1;
13print "ok 1\n";
14
15######################### End of black magic.
16
17my $not = 'not ';
18
19my %hash;
20
21my $parser = Parse::FixedLength->new([qw(
22 first_name:10
23 last_name:10
24 address:20
25)], {href => \%hash});
26
27print $not unless defined $parser;
28print "ok 2\n";
29
30my $data = 'Bob       Jones     1122 Main St.       ';
31$parser->parse($data);
32
33print $not unless $hash{first_name} eq 'Bob';
34print "ok 3\n";
35
36print $not unless $hash{last_name} eq 'Jones';
37print "ok 4\n";
38
39print $not unless $hash{address} eq '1122 Main St.';
40print "ok 5\n";
41
42print $not unless $parser->length == 40;
43print "ok 6\n";
44
45print $not unless $parser->length('first_name') == 10;
46print "ok 7\n";
47