summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSlaven Rezic <slaven@rezic.de>2012-05-21 17:01:01 +0200
committerOlaf Alders <olaf@wundersolutions.com>2015-06-22 12:35:28 -0400
commit4fd7ab9645a0e534558f4994e454624a8ffdef7a (patch)
tree7849a82df816ff191a8aa43fb306258a1ea0c17e /t
parente5f9c524526949b76bb3ec5df1c499f95893f990 (diff)
downloaduri-4fd7ab9645a0e534558f4994e454624a8ffdef7a.tar.gz
Add new test script t/path-segments.t
Diffstat (limited to 't')
-rwxr-xr-xt/path-segments.t33
1 files changed, 33 insertions, 0 deletions
diff --git a/t/path-segments.t b/t/path-segments.t
new file mode 100755
index 0000000..6b11f1c
--- /dev/null
+++ b/t/path-segments.t
@@ -0,0 +1,33 @@
+#!perl -w
+
+use strict;
+use Test::More 'no_plan';
+
+use URI ();
+
+{
+ my $u = URI->new("http://www.example.org/a/b/c");
+
+ is_deeply [$u->path_segments], ['', qw(a b c)], 'path_segments in list context';
+ is $u->path_segments, '/a/b/c', 'path_segments in scalar context';
+
+ is_deeply [$u->path_segments('', qw(z y x))], ['', qw(a b c)], 'set path_segments in list context';
+ is $u->path_segments('/i/j/k'), '/z/y/x', 'set path_segments in scalar context';
+
+ $u->path_segments('', qw(q r s));
+ is $u->path_segments, '/q/r/s', 'set path_segments in void context';
+}
+
+{
+ my $u = URI->new("http://www.example.org/abc");
+ $u->path_segments('', '%', ';', '/');
+ is $u->path_segments, '/%25/%3B/%2F', 'escaping special characters';
+}
+
+{
+ my $u = URI->new("http://www.example.org/abc;param1;param2");
+ my @ps = $u->path_segments;
+ isa_ok $ps[1], 'URI::_segment';
+ $u->path_segments(@ps);
+ is $u->path_segments, '/abc;param1;param2', 'dealing with URI segments';
+}