1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use Test::More tests => 6; |
use Test::More tests => 10; |
4 |
use Test::Exception; |
use Test::Exception; |
5 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
6 |
use blib; |
use blib; |
14 |
$abs_path =~ s#/[^/]*$#/#; |
$abs_path =~ s#/[^/]*$#/#; |
15 |
diag "abs_path: $abs_path"; |
diag "abs_path: $abs_path"; |
16 |
|
|
17 |
throws_ok { new WebPAC::Normalize::XML() } qr/tag/, "new without tag"; |
throws_ok { new WebPAC::Normalize::XML( lookup_regex => 'foo' ) } qr/pair/, "lookup_regex without lookup"; |
18 |
throws_ok { new WebPAC::Normalize::XML( tag => 'isis' ) } qr/xml_file/, "new without xml_file"; |
throws_ok { new WebPAC::Normalize::XML( lookup => 'bar' ) } qr/pair/, "lookup without lookup_regex"; |
19 |
throws_ok { new WebPAC::Normalize::XML( tag => 'isis', xml_file => 'foo' ) } qr/file.*doesn't exist/, "new with invalid xml_file"; |
|
20 |
ok(my $isis = new WebPAC::Normalize::XML( |
ok(my $n = new WebPAC::Normalize::XML( debug => 0 ), "new"); |
21 |
|
|
22 |
|
throws_ok { $n->open() } qr/tag/, "open without tag"; |
23 |
|
throws_ok { $n->open( tag => 'isis' ) } qr/xml_file/, "open without xml_file"; |
24 |
|
throws_ok { $n->open( tag => 'isis', xml_file => 'foo' ) } qr/file.*doesn't exist/, "open with invalid xml_file"; |
25 |
|
ok( $n->open( |
26 |
tag => 'isis', |
tag => 'isis', |
27 |
xml_file => "$abs_path../conf/normalize/isis.xml", |
xml_file => "$abs_path../conf/normalize/isis.xml", |
28 |
debug => 1, |
), "open"); |
29 |
), "new"); |
|
30 |
|
my $rec = { |
31 |
|
'000' => [ '001' ], |
32 |
|
'800' => [ 'foo' ], |
33 |
|
'900' => [ 'bar' ], |
34 |
|
}; |
35 |
|
|
36 |
|
ok(my @ds = $n->data_structure( $rec ), "data_structure"); |
37 |
|
|