| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::More; |
| 4 |
use WWW::Form::UrlEncoded::XS qw/parse_urlencoded_arrayref/; |
| 5 |
use JSON; |
| 6 |
|
| 7 |
while (<DATA>) { |
| 8 |
chomp; |
| 9 |
next unless $_; |
| 10 |
my ($s,$t) = split /\s+=>\s/, $_,2; |
| 11 |
$s =~ s/'//g; |
| 12 |
my $param = parse_urlencoded_arrayref($s); |
| 13 |
is JSON::encode_json($param), $t, $s; |
| 14 |
} |
| 15 |
|
| 16 |
done_testing(); |
| 17 |
|
| 18 |
__DATA__ |
| 19 |
'a=b&c=d' => ["a","b","c","d"] |
| 20 |
'a=b;c=d' => ["a","b","c","d"] |
| 21 |
'a=1&b=2;c=3' => ["a","1","b","2","c","3"] |
| 22 |
'a==b&c==d' => ["a","=b","c","=d"] |
| 23 |
'a=b& c=d' => ["a","b","c","d"] |
| 24 |
'a=b; c=d' => ["a","b","c","d"] |
| 25 |
'a=b; c =d' => ["a","b","c ","d"] |
| 26 |
'a=b;c= d ' => ["a","b","c"," d "] |
| 27 |
'a=b&+c=d' => ["a","b"," c","d"] |
| 28 |
'a=b&+c+=d' => ["a","b"," c ","d"] |
| 29 |
'a=b&c=+d+' => ["a","b","c"," d "] |
| 30 |
'a=b&%20c=d' => ["a","b"," c","d"] |
| 31 |
'a=b&%20c%20=d' => ["a","b"," c ","d"] |
| 32 |
'a=b&c=%20d%20' => ["a","b","c"," d "] |
| 33 |
'a&c=d' => ["a","","c","d"] |
| 34 |
'a=b&=d' => ["a","b","","d"] |
| 35 |
'a=b&=' => ["a","b","",""] |
| 36 |
'a=&' => ["a","","",""] |
| 37 |
'&' => ["","","",""] |
| 38 |
'=' => ["",""] |
| 39 |
'' => [] |
| 40 |
|