File: cow.t

package info (click to toggle)
libencode-perl 3.08-1%2Bdeb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,208 kB
  • sloc: perl: 4,395; ansic: 1,077; makefile: 8
file content (27 lines) | stat: -rw-r--r-- 729 bytes parent folder | download | duplicates (9)
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
#
# $Id: cow.t,v 1.2 2016/08/04 03:15:58 dankogai Exp $
#
use strict;
use Encode ();
use Test::More tests => 4;


my %a = ( "L\x{c3}\x{a9}on" => "acme" );
my ($k) = ( keys %a );
Encode::_utf8_on($k);
my %h = ( $k => "acme" );
is $h{"L\x{e9}on"} => 'acme';
($k) = ( keys %h );
Encode::_utf8_off($k);
%a = ( $k => "acme" );
is $h{"L\x{e9}on"} => 'acme';
# use Devel::Peek;
# Dump(\%h);

{ # invalid input to encode/decode/from_to should not affect COW-shared scalars
	my $x = Encode::decode('UTF-8', "\303\244" x 4);
	my $orig = "$x"; # non-COW copy
	is($x, $orig, "copy of original string matches");
	{ my $y = $x; Encode::from_to($y, "UTF-8", "iso-8859-1"); }
	is($x, $orig, "original scalar unmodified after from_to() call");
}