File: 01-citeparse.t

package info (click to toggle)
libbiblio-citation-parser-perl 1.10%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 660 kB
  • sloc: perl: 3,793; sh: 51; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,322 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/env perl

BEGIN {
  unless(grep /blib/, @INC) {
    chdir 't' if -d 't';
    unshift @INC, '../lib' if -d '../lib';
  }
}
use Test;

BEGIN { plan tests => 7 }

use Biblio::Citation::Parser::Standard;
{ # check 'use ...'
  print "'use Biblio::Citation::Parser...' test(s)...\n";

  eval "use Biblio::Citation::Parser 99.99";

  ok($@ =~ /99\.99 required/);
}

# Check a simple ref

{
  my $ref = "Jewell, M (2002) Making Examples for Reference Parsers. Journal of Example Writing 3:100-150.";
  my $cit_parser = new Biblio::Citation::Parser::Standard;
  my $metadata = $cit_parser->parse($ref);
  ok(scalar keys %$metadata == 14);
  ok($metadata->{pages} eq "100-150");
  ok($metadata->{title} eq "Journal of Example Writing");
  # Do a few OpenURL util checks

  use Biblio::Citation::Parser::Utils;

  # Add a spurious key
  $metadata->{foo} = "bar";
  $metadata = trim_openurl($metadata);
  ok(!$metadata->{foo});
  ($metadata,undef) = decompose_openurl($metadata);
  ok($metadata->{spage} eq "100");
}

# Test the Jiao module

{
  use Biblio::Citation::Parser::Jiao;
  my $ref = "Jewell, M (2002) Making Examples for Reference Parsers. Journal of Example Writing 3:100-150.";
  my $cit_parser = new Biblio::Citation::Parser::Jiao;
  my $metadata = $cit_parser->parse($ref);
  ok($metadata->{spage} eq "100"); 
}