File: 03-hashu.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 (32 lines) | stat: -rw-r--r-- 866 bytes parent folder | download | duplicates (3)
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
#!perl -w
#
# $Id: 03-hashu.t,v 0.3 2014/01/20 20:39:54 dankogai Exp $
#
# Original as URI-1.35/t/escape.t
#

use URI::Escape::XS;
use Test::More tests => 6;
use Encode;

my %esc =
  map { encode_utf8($_) } (
    '%uHHHH'                   => "%uHHHH",
    '%uD869%uDEB2%u5F3E%u0064' => "\x{2a6b2}\x{5F3E}d"
  );

for my $k (keys %esc) {
    is decodeURIComponent($k) => $esc{$k}, qq{decodeURI("$k")};
}

{
    # Test::Harness 3.x hates me!
    # skip 'Test::Harness->VERSION > 3', 4
    #   if Test::Harness->can('VERSION') and Test::Harness->VERSION >= 3;
    my $warn;
    local($SIG{__WARN__}) = sub { $warn = shift };
    is decodeURIComponent('%uD869') => '', qq{decodeURI("%uD869")};
    like $warn => qr/lo surrogate is missing/, $warn;
    is decodeURIComponent('%uDEB2') => '', qq{decodeURI("%uDEB2")};
    like $warn => qr/invalid surrogate hi/, $warn;
}