diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-07-19 17:50:38 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-07-19 17:50:38 +0000 |
commit | d403562e3f7ac96df7cee2c1709ecd970b6c9761 (patch) | |
tree | 0c8ec1bc7a6e0bf408a0e183b52ef7de174cde9a /t/headers-util.t | |
download | HTTP-Message-tarball-master.tar.gz |
HTTP-Message-6.10HEADHTTP-Message-6.10master
Diffstat (limited to 't/headers-util.t')
-rw-r--r-- | t/headers-util.t | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/t/headers-util.t b/t/headers-util.t new file mode 100644 index 0000000..ee7717a --- /dev/null +++ b/t/headers-util.t @@ -0,0 +1,45 @@ +use strict; +use warnings; + +use Test::More; + +use HTTP::Headers::Util qw(split_header_words join_header_words); + +my @s_tests = ( + + ["foo" => "foo"], + ["foo=bar" => "foo=bar"], + [" foo " => "foo"], + ["foo=" => 'foo=""'], + ["foo=bar bar=baz" => "foo=bar; bar=baz"], + ["foo=bar;bar=baz" => "foo=bar; bar=baz"], + ['foo bar baz' => "foo; bar; baz"], + ['foo="\"" bar="\\\\"' => 'foo="\""; bar="\\\\"'], + ['foo,,,bar' => 'foo, bar'], + ['foo=bar,bar=baz' => 'foo=bar, bar=baz'], + + ['TEXT/HTML; CHARSET=ISO-8859-1' => + 'text/html; charset=ISO-8859-1'], + + ['foo="bar"; port="80,81"; discard, bar=baz' => + 'foo=bar; port="80,81"; discard, bar=baz'], + + ['Basic realm="\"foo\\\\bar\""' => + 'basic; realm="\"foo\\\\bar\""'], +); + +plan tests => @s_tests + 2; + +for (@s_tests) { + my($arg, $expect) = @$_; + my @arg = ref($arg) ? @$arg : $arg; + + my $res = join_header_words(split_header_words(@arg)); + is($res, $expect); +} + + +note "# Extra tests\n"; +# some extra tests +is(join_header_words("foo" => undef, "bar" => "baz"), "foo; bar=baz"); +is(join_header_words(), ""); |