File: parse_hash.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 (77 lines) | stat: -rw-r--r-- 1,284 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!perl

use Test::More;

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

sub test {
    my %a = HTTP::Link->parse_hash(shift);

    #use Data::Dumper;
    #diag Dumper(\%a);
    my %b = @_;
    @_ = ( \%a, \%b );
    goto &Test::More::is_deeply;
}

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

test(
    <<'EOT',
<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"
EOT
    A => {
        relation  => 'B',
        extension => 'X',
        anchor    => 'C',
        rev       => 'D',
        hreflang  => 'E',
        media     => 'F',
        title     => 'G',
    },
    I => {
        relation  => 'J',
        extension => 'K',
        anchor    => 'L',
        rev       => 'M',
        hreflang  => 'N',
        media     => 'O',
        title     => 'P',
    }
);

00 && test(<<'EOT');
</TheBook/chapter2>;
rel="previous"; title*=UTF-8'de'letztes%20Kapitel,
</TheBook/chapter4>;
rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel
EOT

done_testing;