File: 02-basic.t

package info (click to toggle)
liburi-escape-xs-perl 0.12-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 144 kB
  • ctags: 3
  • sloc: perl: 239; makefile: 2
file content (18 lines) | stat: -rw-r--r-- 475 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!perl -w
#
# $Id: 02-basic.t,v 0.1 2007/04/27 17:17:46 dankogai Exp $
#
# Original as URI-1.35/t/escape.t
#

use URI::Escape::XS;
use Test::More tests => 512;

# basic round-trip test
for my $ord (  0 .. 255 ) {
    use bytes;
    my $chr = chr $ord;
    my $esc = $chr =~ /[A-Za-z0-9\-_.!~*'()]/ ? $chr : sprintf "%%%02X", $ord;
    is encodeURIComponent($chr) => $esc, "encodeURIComponent(ord $ord)";
    is decodeURIComponent($esc) => $chr, "decodeURIComponent($esc)";
}