X-Git-Url: http://erislabs.net/gitweb/?p=liburi-template-perl.git;a=blobdiff_plain;f=t%2F12-suite.t;fp=t%2F12-suite.t;h=19b091496d86a99d97ee645f1831dc80ee057a25;hp=0000000000000000000000000000000000000000;hb=e0de6ab08282e52476e36abb99a35be9eff9ca8e;hpb=90a266f52eaecdd5e15d16fe4fa3b98cb184c67c diff --git a/t/12-suite.t b/t/12-suite.t new file mode 100644 index 0000000..19b0914 --- /dev/null +++ b/t/12-suite.t @@ -0,0 +1,31 @@ +use strict; +use warnings; + +use Test::More; + +BEGIN { + eval "use JSON ();"; + plan skip_all => "JSON required" if $@; + plan( 'no_plan' ); + use_ok( 'URI::Template' ); +} + +my @files = glob( 't/data/*.json' ); + +for my $file ( @files ) { + open( my $json, $file ); + my $suite = JSON::jsonToObj( do { local $/; <$json> } ); + close( $json ); + + my %variables = %{ $suite->{ variables } }; + + my $count = 0; + for my $test ( @{ $suite->{ tests } } ) { + my $template = URI::Template->new( $test->{ template } ); + my $result = $template->process( %variables ); + $count++; + is( $result, $test->{ expected }, "${file}#${count}" ); + } +} + +