Blame t/13utf8.t

Packit Service a45ac5
#!/usr/bin/perl
Packit Service f99136
Packit Service f99136
#
Packit Service f99136
# Test the use of utf8 strings
Packit Service f99136
#
Packit Service f99136
Packit Service f99136
use Convert::ASN1;
Packit Service f99136
BEGIN { require 't/funcs.pl' }
Packit Service f99136
Packit Service f99136
if ($] < 5.007) {
Packit Service f99136
  print "1..0\n";
Packit Service f99136
  exit;
Packit Service f99136
}
Packit Service f99136
Packit Service f99136
print "1..12\n";
Packit Service f99136
Packit Service f99136
btest 1, $asn  = Convert::ASN1->new() or warn $asn->error;
Packit Service f99136
btest 2, $asn->prepare(q(
Packit Service f99136
    str STRING
Packit Service f99136
)) or warn $asn->error;
Packit Service f99136
Packit Service f99136
my $result = pack("C*", 0x04, 0x07, 0x75, 0x74, 0x66, 0x38, 0x20, 0xc6, 0x81);
Packit Service f99136
stest 3, $result, $asn->encode(str => "utf8 " . chr(0x181)) or warn $asn->error;
Packit Service f99136
Packit Service f99136
btest 4, $ret = $asn->decode($result) or warn $asn->error;
Packit Service f99136
stest 5, "utf8 " . chr(0xc6) . chr(0x81), $ret->{str};
Packit Service f99136
Packit Service f99136
Packit Service f99136
btest 6, $asn->prepare(q(
Packit Service f99136
    str UTF8String
Packit Service f99136
)) or warn $asn->error;
Packit Service f99136
my $utf_str = "utf8 " . chr(0x181);
Packit Service f99136
Packit Service f99136
$result = pack("C*", 0x0c, 0x07, 0x75, 0x74, 0x66, 0x38, 0x20, 0xc6, 0x81);
Packit Service f99136
stest 7, $result, $asn->encode(str => $utf_str) or warn $asn->error;
Packit Service f99136
Packit Service f99136
btest 8, $ret = $asn->decode($result) or warn $asn->error;
Packit Service f99136
stest 9, $utf_str, $ret->{str};
Packit Service f99136
Packit Service f99136
# Test that UTF8String will upgrade on encoding
Packit Service f99136
$result = pack("C*", 0x0c, 0x02, 0xc2, 0x81);
Packit Service f99136
stest 10, $result, $asn->encode(str => chr(0x81)) or warn $asn->error;
Packit Service f99136
Packit Service f99136
btest 11, $ret = $asn->decode($result) or warn $asn->error;
Packit Service f99136
stest 12, chr(0x81), $ret->{str};