summaryrefslogtreecommitdiff
path: root/t/headers-util.t
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-07-19 17:50:38 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-07-19 17:50:38 +0000
commitd403562e3f7ac96df7cee2c1709ecd970b6c9761 (patch)
tree0c8ec1bc7a6e0bf408a0e183b52ef7de174cde9a /t/headers-util.t
downloadHTTP-Message-tarball-master.tar.gz
Diffstat (limited to 't/headers-util.t')
-rw-r--r--t/headers-util.t45
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(), "");