@@ -2,12 +2,14 @@ use strict;
22use warnings;
33
44use Test::More;
5+ use Data::Dumper;
56
67BEGIN {
78 use_ok(' URL::Encode::PP' , qw[ url_params_each
89 url_params_flat
910 url_params_mixed
10- url_params_multi ] );
11+ url_params_multi
12+ url_params_build ] );
1113}
1214
1315{
@@ -123,5 +125,44 @@ BEGIN {
123125 is($cnt , 3, ' url_params_each(): callback invoked three times' );
124126}
125127
128+ {
129+ my @tests = (
130+ [ ' b=&a=' , => [ ' b' => undef , ' a' => undef ] ],
131+ [ ' a=&a=&b=' , => [ ' a' => [ undef , undef ], ' b' => undef ] ],
132+ [ ' a=&a=&b=&b=' , => [ ' a' => [ undef , undef ], ' b' => [ undef , undef ] ] ],
133+ [ ' a+=&+b=' , => [ ' a ' => undef , ' b' => undef ] ],
134+ [ ' a=%3D1&b=%3D2' , => [ ' a' => ' =1' , ' b' => ' =2' ] ],
135+ [ ' Fo%252=' , => [ ' Fo%2' => ' ' ] ],
136+ [ ' +a+=+1+' => [ ' a ' => ' 1 ' ] ],
137+ [ ' =&=' => [ ' ' => [ undef , undef ], ] ],
138+ [ ' =&=' => [ ' ' => [ undef , ' ' ] ] ],
139+ [ ' =&=' => [ ' ' => [ ' ' , undef ] ] ],
140+ [ ' =&=' => [ ' ' => [ ' ' , ' ' ] ] ],
141+ [ ' =' , => [ ' ' => ' ' , ] ],
142+ [ ' ' , => [ ] ],
143+ [ ' a=&b=' , => { ' b' => undef , ' a' => undef } ],
144+ [ ' a=&a=&b=' , => { ' a' => [ undef , undef ], ' b' => undef } ],
145+ [ ' a=&a=&b=&b=' , => { ' a' => [ undef , undef ], ' b' => [ undef , undef ] } ],
146+ [ ' +b=&a+=' , => { ' a ' => undef , ' b' => undef } ],
147+ [ ' a=%3D1&b=%3D2' , => { ' a' => ' =1' , ' b' => ' =2' } ],
148+ [ ' Fo%252=' , => { ' Fo%2' => ' ' } ],
149+ [ ' +a+=+1+' => { ' a ' => ' 1 ' } ],
150+ [ ' =&=' => { ' ' => [ undef , undef ], } ],
151+ [ ' =&=' => { ' ' => [ undef , ' ' ] } ],
152+ [ ' =&=' => { ' ' => [ ' ' , undef ] } ],
153+ [ ' =&=' => { ' ' => [ ' ' , ' ' ] } ],
154+ [ ' =' , => { ' ' => ' ' , } ],
155+ [ ' ' , => { } ],
156+ );
157+
158+ foreach my $test (@tests ) {
159+ my ($expected , $params ) = @$test ;
160+ local $Data::Dumper::Indent = 0;
161+ local $Data::Dumper::Terse = 1;
162+ my $params_str = Dumper($params );
163+ is_deeply(url_params_build($params ), $expected , qq[ url_params_build("$params_str ")] );
164+ }
165+ }
166+
126167done_testing();
127168
0 commit comments