Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add new test script t/path-segments.t #10

Open
wants to merge 1 commit into from

1 participant

Slaven Rezić
Slaven Rezić

This change increases test coverage of the URI::_generic::path_segments method to 100%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 21, 2012
  1. Slaven Rezić
This page is out of date. Refresh to see the latest.
Showing with 33 additions and 0 deletions.
  1. +33 −0 t/path-segments.t
33 t/path-segments.t
View
@@ -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';
+}
Something went wrong with that request. Please try again.