File: param_parser.t

package info (click to toggle)
libweb-simple-perl 0.002%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 228 kB
  • ctags: 202
  • sloc: perl: 1,995; sh: 48; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 614 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use strict;
use warnings FATAL => 'all';

use Test::More qw(no_plan);

use Web::Simple::ParamParser;

my $param_sample = 'foo=bar&baz=quux&foo=%2F';
my $unpacked = {
  baz => [
    "quux"
  ],
  foo => [
    "bar",
    "/"
  ]
};

is_deeply(
  Web::Simple::ParamParser::_unpack_params('foo=bar&baz=quux&foo=%2F'),
  $unpacked,
  'Simple unpack ok'
);

my $env = { 'QUERY_STRING' => $param_sample };

is_deeply(
  Web::Simple::ParamParser::get_unpacked_query_from($env),
  $unpacked,
  'Dynamic unpack ok'
);

is_deeply(
  $env->{+Web::Simple::ParamParser::UNPACKED_QUERY},
  $unpacked,
  'Unpack cached ok'
);

1;