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
|
use strict;
use Test::More;
use Plack::Util;
{
my $headers = [ Foo => 'bar' ];
Plack::Util::header_set($headers, Bar => 'baz');
is_deeply $headers, [ Foo => 'bar', Bar => 'baz' ];
}
{
my $headers = [ Foo => 'bar' ];
Plack::Util::header_set($headers, Foo => 'baz');
is_deeply $headers, [ Foo => 'baz' ];
}
{
my $headers = [ Foo => 'bar' ];
Plack::Util::header_set($headers, foo => 'baz');
is_deeply $headers, [ Foo => 'baz' ], 'header_set case-insensitive';
}
{
my $headers = [ Foo => 'bar' ];
is Plack::Util::header_get($headers, 'Foo'), 'bar';
}
{
my $headers = [ Foo => 'bar' ];
is Plack::Util::header_get($headers, 'foo'), 'bar', 'header_get case-insensitive'
}
{
my $headers = [ Foo => 'bar', Bar => 'baz' ];
Plack::Util::header_push($headers, Foo => 'quox');
is_deeply $headers, [ Foo => 'bar', Bar => 'baz', Foo => 'quox' ];
}
{
my $headers = [ Foo => 'bar', Bar => 'baz' ];
Plack::Util::header_remove($headers, 'Foo');
is_deeply $headers, [ Bar => 'baz' ];
}
{
my $headers = [ Foo => 'bar', Bar => 'baz' ];
Plack::Util::header_remove($headers, 'foo');
is_deeply $headers, [ Bar => 'baz' ], 'header_remove case-insensitive';
}
{
my $headers = [ Foo => 'bar', Bar => 'baz' ];
is Plack::Util::header_exists($headers, 'Foo'), 1;
}
{
my $headers = [ Foo => 'bar', Foo => 'baz' ];
Plack::Util::header_set($headers, Foo => 'quox');
is_deeply $headers, [ Foo => 'quox' ];
}
done_testing;
|