Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 89 lines (67 sloc) 2.473 kb
a282355 initial commit
Ryo Anazawa authored
1 use strict;
2 use warnings;
2343ffb doesn't provide hash slices
Ryo Anazawa authored
3 use CGI::Header;
da2d4e8 Checking in changes prior to tagging of version 0.01.
Ryo Anazawa authored
4 use Test::More tests => 27;
53f1c25 Can't set Content-Type to neither undef nor an empty string
Ryo Anazawa authored
5 use Test::Warn;
a282355 initial commit
Ryo Anazawa authored
6
7 my %adaptee;
2343ffb doesn't provide hash slices
Ryo Anazawa authored
8 my $adapter = tie my %adapter, 'CGI::Header', \%adaptee;
a282355 initial commit
Ryo Anazawa authored
9
10 %adaptee = ( -type => q{} );
11 is $adapter{Content_Type}, undef;
12 ok !exists $adapter{Content_Type};
13 is delete $adapter{Content_Type}, undef;
14
15 %adaptee = ();
16 is $adapter{Content_Type}, 'text/html; charset=ISO-8859-1';
17 ok exists $adapter{Content_Type};
18 is delete $adapter{Content_Type}, 'text/html; charset=ISO-8859-1';
19 is_deeply \%adaptee, { -type => q{} };
20
21 %adaptee = ( -type => 'text/plain' );
22 is $adapter{Content_Type}, 'text/plain; charset=ISO-8859-1';
23 ok exists $adapter{Content_Type};
24
8063e3c add tests
Ryo Anazawa authored
25 %adaptee = ( -type => undef );
26 is $adapter{Content_Type}, 'text/html; charset=ISO-8859-1';
27 ok exists $adapter{Content_Type};
28 ok %adapter;
29
30 %adaptee = ( -type => undef, -charset => 'utf-8' );
31 is $adapter{Content_Type}, 'text/html; charset=utf-8';
32
33 %adaptee = ( -type => 'text/plain', -charset => 'utf-8' );
34 is delete $adapter{Content_Type}, 'text/plain; charset=utf-8';
35 is_deeply \%adaptee, { -type => q{} };
36
37 # feature
38 %adaptee = ( -type => 'text/plain; charSet=utf-8' );
39 is $adapter{Content_Type}, 'text/plain; charSet=utf-8; charset=ISO-8859-1';
a282355 initial commit
Ryo Anazawa authored
40
41 # FETCH
42
43 %adaptee = ( -charset => 'utf-8' );
44 is $adapter{Content_Type}, 'text/html; charset=utf-8';
45
46 %adaptee = ( -type => q{}, -charset => 'utf-8' );
47 is $adapter{Content_Type}, undef;
48
49 %adaptee = ( -type => 'text/plain; charset=EUC-JP' );
50 is $adapter{Content_Type}, 'text/plain; charset=EUC-JP';
51
52 %adaptee = (
53 -type => 'text/plain; charset=euc-jp',
54 -charset => 'utf-8',
55 );
56 is $adapter{Content_Type}, 'text/plain; charset=euc-jp';
57
58 %adaptee = ( -charset => q{} );
59 is $adapter{Content_Type}, 'text/html';
60
61 %adaptee = ( -type => 'text/plain; Foo=1', -charset => 'utf-8' );
62 is $adapter{Content_Type}, 'text/plain; Foo=1; charset=utf-8';
63
64
65 # STORE
66
67 %adaptee = ();
68 $adapter{Content_Type} = 'text/plain; charset=utf-8';
69 is_deeply \%adaptee, {
70 -type => 'text/plain; charset=utf-8',
71 -charset => q{}
72 };
73
74 %adaptee = ();
75 $adapter{Content_Type} = 'text/plain';
76 is_deeply \%adaptee, { -type => 'text/plain', -charset => q{} };
77
78 %adaptee = ( -charset => 'euc-jp' );
79 $adapter{Content_Type} = 'text/plain; charset=utf-8';
80 is_deeply \%adaptee, {
81 -type => 'text/plain; charset=utf-8',
82 -charset => q{},
83 };
84
8063e3c add tests
Ryo Anazawa authored
85 %adaptee = ();
53f1c25 Can't set Content-Type to neither undef nor an empty string
Ryo Anazawa authored
86 warning_is { $adapter{Content_Type} = q{} }
87 "Can't set '-content_type' to neither undef nor an empty string";
88 is_deeply \%adaptee, {};
Something went wrong with that request. Please try again.