File: parse.t

package info (click to toggle)
libhttp-link-perl 0.001-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 156 kB
  • sloc: perl: 475; makefile: 2; sh: 1
file content (58 lines) | stat: -rw-r--r-- 1,325 bytes parent folder | download
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
52
53
54
55
56
57
58
#!perl

use Test::More;

BEGIN {
    use_ok('HTTP::Link');
}

sub test {
    my @a = HTTP::Link->parse(shift);
    my @b = @_;
    @_ = ( \@a, \@b );
    goto &Test::More::is_deeply;
}

test(
    '<A>; rel="B X"; anchor="C"; rev="D"; hreflang="E"; media="F"; title="G"',
    {
        iri       => 'A',
        relation  => 'B',
        extension => 'X',
        anchor    => 'C',
        rev       => 'D',
        hreflang  => 'E',
        media     => 'F',
        title     => 'G',
    }
);

test(
'<A>; rel="B X"; anchor="C"; rev="D"; hreflang="E"; media="F"; title="G", <I>; rel="J K"; anchor="L"; rev="M"; hreflang="N"; media="O"; title="P"',
    {
        iri       => 'A',
        relation  => 'B',
        extension => 'X',
        anchor    => 'C',
        rev       => 'D',
        hreflang  => 'E',
        media     => 'F',
        title     => 'G',
    },
    {
        iri       => 'I',
        relation  => 'J',
        extension => 'K',
        anchor    => 'L',
        rev       => 'M',
        hreflang  => 'N',
        media     => 'O',
        title     => 'P',
    }
);

test( '<A>; title*="=?UTF-8?B?Ig==?="', { iri => 'A', title => '"' } );
test( '<A>; title*="=?UTF-8?B?Pw==?="', { iri => 'A', title => '?' } );
test( '<A>; title*="=?UTF-8?B?PQ==?="', { iri => 'A', title => '=' } );

done_testing;