File: decode.t

package info (click to toggle)
libencode-perl 2.63-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 10,944 kB
  • ctags: 220
  • sloc: perl: 4,185; ansic: 120; makefile: 7
file content (25 lines) | stat: -rw-r--r-- 514 bytes parent folder | download | duplicates (6)
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
#
# $Id: decode.t,v 1.1 2013/08/29 16:47:39 dankogai Exp $
#
use strict;
use Encode qw(decode_utf8 FB_CROAK);
use Test::More tests => 3;

sub croak_ok(&) {
    my $code = shift;
    eval { $code->() };
    like $@, qr/does not map/;
}

my $bytes = "L\x{e9}on";
my $pad = "\x{30C9}";

my $orig = $bytes;
croak_ok { Encode::decode_utf8($orig, FB_CROAK) };

my $orig2 = $bytes;
croak_ok { Encode::decode('utf-8', $orig2, FB_CROAK) };

chop(my $new = $bytes . $pad);
croak_ok { Encode::decode_utf8($new, FB_CROAK) };