X-Git-Url: http://erislabs.net/gitweb/?p=liburi-template-perl.git;a=blobdiff_plain;f=t%2F20-deparse.t;fp=t%2F20-deparse.t;h=0000000000000000000000000000000000000000;hp=1a1934679b1b027e0ca143efc0402500433f7e8b;hb=c4fd5064ccd0e0c568bec68ebe82f3daf6c235b6;hpb=917525490f5d8e583f4b53dcd2d792b9e6f42c88 diff --git a/t/20-deparse.t b/t/20-deparse.t deleted file mode 100644 index 1a19346..0000000 --- a/t/20-deparse.t +++ /dev/null @@ -1,54 +0,0 @@ -use strict; -use warnings; - -use Test::More tests => 13; - -use_ok( 'URI::Template' ); - -{ - my $template - = URI::Template->new( 'http://{domain}.com/{dir}/{file}.html' ); - isa_ok( $template, 'URI::Template' ); - my %result = $template->deparse( 'http://example.com/test/1.html' ); - is_deeply( \%result, { domain => 'example', dir => 'test', file => '1' }, - 'deparse()' ); -} - -{ - my $template = URI::Template->new( 'http://test.com/{x}/{y}/{x}/{y}' ); - isa_ok( $template, 'URI::Template' ); - my %result = $template->deparse( 'http://test.com/1/2/1/2' ); - is_deeply( - \%result, - { x => 1, y => 2 }, - 'deparse() with multiple values' - ); -} - -{ - my $template = URI::Template->new( 'http://ex.com/{x}' ); - isa_ok( $template, 'URI::Template' ); - my %input = ( x => 'y' ); - my $uri = $template->process( x => 'y' ); - is( $uri, 'http://ex.com/y' ); - my %result = $template->deparse( $uri ); - is_deeply( \%result, \%input, 'process => deparse' ); -} - -{ - my $template = URI::Template->new( 'http://ex.com/{test}' ); - isa_ok( $template, 'URI::Template' ); - my %input = ( test => 'test' ); - my $uri = $template->process( test => 'test' ); - is( $uri, 'http://ex.com/test' ); - my %result = $template->deparse( $uri ); - is_deeply( \%result, \%input, 'process => deparse w/ multiple chars' ); -} - -{ - my $template = URI::Template->new( 'http://ex.com/profile/{username}/address' ); - isa_ok( $template, 'URI::Template' ); - my $uri = 'http://ex.com/profile/Test/addresses'; - my %result = $template->deparse( $uri ); - is_deeply( \%result, { username => undef }, 'regex properly terminated' ); -}