Debian Codegraph @

t/01-citeparse.t

raw
1 #!/bin/env perl
2
3 BEGIN {
4 unless(grep /blib/, @INC) {
5 chdir 't' if -d 't';
6 unshift @INC, '../lib' if -d '../lib';
7 }
8 }
9 use Test;
10
11 BEGIN { plan tests => 7 }
12
13 use Biblio::Citation::Parser::Standard;
14 { # check 'use ...'
15 print "'use Biblio::Citation::Parser...' test(s)...\n";
16
17 eval "use Biblio::Citation::Parser 99.99";
18
19 ok($@ =~ /99\.99 required/);
20 }
21
22 # Check a simple ref
23
24 {
25 my $ref = "Jewell, M (2002) Making Examples for Reference Parsers. Journal of Example Writing 3:100-150.";
26 my $cit_parser = new Biblio::Citation::Parser::Standard;
27 my $metadata = $cit_parser->parse($ref);
28 ok(scalar keys %$metadata == 14);
29 ok($metadata->{pages} eq "100-150");
30 ok($metadata->{title} eq "Journal of Example Writing");
31 # Do a few OpenURL util checks
32
33 use Biblio::Citation::Parser::Utils;
34
35 # Add a spurious key
36 $metadata->{foo} = "bar";
37 $metadata = trim_openurl($metadata);
38 ok(!$metadata->{foo});
39 ($metadata,undef) = decompose_openurl($metadata);
40 ok($metadata->{spage} eq "100");
41 }
42
43 # Test the Jiao module
44
45 {
46 use Biblio::Citation::Parser::Jiao;
47 my $ref = "Jewell, M (2002) Making Examples for Reference Parsers. Journal of Example Writing 3:100-150.";
48 my $cit_parser = new Biblio::Citation::Parser::Jiao;
49 my $metadata = $cit_parser->parse($ref);
50 ok($metadata->{spage} eq "100");
51 }