X-Git-Url: http://erislabs.net/gitweb/?p=liburi-template-perl.git;a=blobdiff_plain;f=t%2F20-deparse.t;h=4fac4b3d2b7640b8fd8cc2ca5a142d2c5e279d35;hp=fd112e0fb12c8e8aa1b27968848b74ca7ae79823;hb=6ce2a97438a9ca90e550caeefb1d3cecf259ded4;hpb=3f3d56e5fb9a55ee113ccf2bc03f3a453f80baa0 diff --git a/t/20-deparse.t b/t/20-deparse.t index fd112e0..4fac4b3 100644 --- a/t/20-deparse.t +++ b/t/20-deparse.t @@ -1,30 +1,46 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 11; use_ok( 'URI::Template' ); { - my $template = URI::Template->new( 'http://{domain}.com/{dir}/{file}.html' ); + 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()' ); + 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' ); + 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' ); + my $uri = $template->process( x => 'y' ); is( $uri, 'http://ex.com/y' ); - my %result = $template->deparse( $uri ); + 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' ); +}