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
|
#!perl
use Test::More;
BEGIN {
use_ok('HTTP::Link');
}
is( HTTP::Link->new('') => '<>' );
is( HTTP::Link->new('A') => '<A>' );
is( HTTP::Link->new('<>') => '<<>>' );
is( HTTP::Link->new( 'A', relation => 'B' ) => '<A>; rel="B"' );
is( HTTP::Link->new( 'A', relation => [qw[ B C D E F ]] ) =>
'<A>; rel="B C D E F"' );
is( HTTP::Link->new( 'A', relation => 'B', extension => 'C' ) =>
'<A>; rel="B C"' );
is( HTTP::Link->new( 'A', anchor => 'B' ) => '<A>; anchor="B"' );
is( HTTP::Link->new( 'A', hreflang => 'B' ) => '<A>; hreflang="B"' );
is( HTTP::Link->new( 'A', media => 'B' ) => '<A>; media="B"' );
is( HTTP::Link->new( 'A', title => 'B' ) => '<A>; title="B"' );
is( HTTP::Link->new( 'A', title => '"' ) => '<A>; title*="=?UTF-8?B?Ig==?="' );
is( HTTP::Link->new( 'A', title => '?' ) => '<A>; title*="=?UTF-8?B?Pw==?="' );
is( HTTP::Link->new( 'A', title => '=' ) => '<A>; title*="=?UTF-8?B?PQ==?="' );
is(
HTTP::Link->new(
'A',
relation => 'B',
extension => 'C',
anchor => 'C',
hreflang => 'E',
media => 'F',
title => 'G'
) => '<A>; rel="B C"; anchor="C"; hreflang="E"; media="F"; title="G"'
);
is(
HTTP::Link->new(
'A',
relation => 'B',
extension => 'C',
anchor => 'C',
hreflang => 'E',
media => 'F',
title => "\xe6\xa1\x9c"
) =>
'<A>; rel="B C"; anchor="C"; hreflang="E"; media="F"; title*="=?UTF-8?B?5qGc?="'
);
done_testing;
|