BEGIN { plan
tests
=> 4 }
sub
compare_internal;
my
$text
=
'Perl'
;
my
$expect
= [
unpack
'C*'
,
$text
];
my
$cd
= Locale::Recode->new (
from
=>
'ISO-8859-1'
,
to
=>
'INTERNAL'
);
ok !
$cd
->getError;
my
$result
=
$text
;
ok
$cd
->recode (
$result
) && compare_internal
$expect
=>
$result
;
$cd
= Locale::Recode->new (
from
=>
'lAtIn2'
,
to
=>
'l3'
);
ok !
$cd
->getError;
$result
=
$expect
=
$text
;
ok
$cd
->recode (
$result
) &&
$result
eq
$expect
;
sub
compare_internal
{
my
(
$bonny
,
$clyde
) =
@_
;
return
unless
defined
$bonny
;
return
unless
defined
$clyde
;
return
unless
'ARRAY'
eq
ref
$bonny
;
return
unless
'ARRAY'
eq
ref
$clyde
;
return
unless
@$bonny
==
@$clyde
;
for
(
my
$i
= 0;
$i
<
@$bonny
; ++
$i
) {
return
unless
$bonny
->[
$i
] ==
$clyde
->[
$i
];
}
return
1;
}