Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Basic test that buf decode gives NFG string.
  • Loading branch information
jnthn committed Apr 24, 2015
1 parent 588ebf6 commit 68891de
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions S15-nfg/from-buf.t
@@ -0,0 +1,31 @@
use Test;

plan 4;

{
# UTF-8 of codepoints 0044 0307 0323
my $utf8 = buf8.new(68, 204, 135, 204, 163);
my $s = $utf8.decode('utf-8');
is $s.chars, 1, 'Decoding a UTF-8 Buf gets us NFG (one codepoint)';
}

{
# UTF-8 of codepoints 0044 0307 0323 0044 0307 0044 0323
my $utf8 = buf8.new(68, 204, 135, 204, 163, 68, 204, 135, 68, 204, 163);
my $s = $utf8.decode('utf-8');
is $s.chars, 3, 'Decoding a UTF-8 Buf gets us NFG (a few codepoints)';
}

{
# UTF-16 of codepoints 0044 0307 0323
my $utf16 = buf16.new(68, 775, 803);
my $s = $utf16.decode('utf-16');
is $s.chars, 1, 'Decoding a UTF-16 Buf gets us NFG (one codepoint)';
}

{
# UTF-16 of codepoints 0044 0307 0323 0044 0307 0044 0323
my $utf16 = buf16.new(68, 775, 803, 68, 775, 68, 803);
my $s = $utf16.decode('utf-16');
is $s.chars, 3, 'Decoding a UTF-16 Buf gets us NFG (a few codepoints)';
}

0 comments on commit 68891de

Please sign in to comment.