Skip to content

Commit 717046a

Browse files
committed
Another test to cover improved ergonomics.
We spit out valid ASCII bytes as they are, for non-UTF-8-C8 output.
1 parent dfb702a commit 717046a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

S32-str/utf8-c8.t

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use Test;
55
# 8-bit octet stream given to us by OSes that don't promise anything about
66
# the character encoding of filenames and so forth.
77

8-
plan 23;
8+
plan 29;
99

1010
{
1111
my $test-str;
@@ -49,6 +49,18 @@ plan 23;
4949
'utf8-c8 round-trips ordinary synthetics';
5050
}
5151

52+
{
53+
my $test-str;
54+
lives-ok { $test-str = Buf.new(ord('L'), 0xE9, ord('o'), ord('n')).decode('utf8-c8') },
55+
'Can decode byte buffer with 0xE9 in middle as utf8-c8';
56+
is $test-str.chars, 4, 'Got expected number of chars';
57+
is $test-str.substr(0, 1), 'L', 'Got first char, which was valid UTF-8';
58+
is $test-str.substr(2, 1), 'o', 'Got third char, which was valid UTF-8';
59+
is $test-str.substr(3, 1), 'n', 'Got forth char, which was valid UTF-8';
60+
is $test-str.encode('utf8-c8').list, (ord('L'), 0xE9, ord('o'), ord('n')),
61+
'Encoding back to utf8-c8 round-trips';
62+
}
63+
5264
{
5365
my $test-file = $*TMPDIR ~ '/tmp.' ~ $*PID ~ '-' ~ time;
5466
LEAVE unlink $test-file;

0 commit comments

Comments
 (0)