Skip to content

Commit

Permalink
Merge pull request #462 from JJ/master
Browse files Browse the repository at this point in the history
Adds test for translate-nl
  • Loading branch information
zoffixznet committed Aug 8, 2018
2 parents b6fc8e0 + 56b4011 commit d422889
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion S32-str/encode.t
Expand Up @@ -3,13 +3,21 @@ use Test;

# L<S32::Containers/Buf>

plan 36;
plan 38;

ok 'ab'.encode('ASCII') ~~ blob8, '$str.encode returns a blob8';
ok ('ab'.encode('ASCII') eqv blob8.new(97, 98)), 'encoding to ASCII';
is 'ab'.encode('ASCII').elems, 2, 'right length of Buf';
ok ('ö'.encode('UTF-8') eqv utf8.new(195, 182)), 'encoding to UTF-8';
is 'ab'.encode('UTF-8').elems, 2, 'right length of Buf';
is "a\nb".encode('utf8').elems, 3, 'right length of Buf with \n';

if $*DISTRO.is-win {
is-deeply "a\nb".encode('utf8', :translate-nl), utf8.new(97,0x0d,0x0a,98), 'Translation of \n in Windows environment';
} else {
is-deeply "a\nb".encode('utf8', :translate-nl), utf8.new(97,0x0a,98), 'Non-translation of \n outside Windows';
}

is 'ö'.encode('UTF-8')[0], 195, 'indexing a utf8 gives correct value (1)';
is 'ö'.encode('UTF-8')[1], 182, 'indexing a utf8 gives correct value (1)';
is '€‚ƒ„…†‡ˆ‰Š‹ŒŽ'.encode('windows-1252').values, (0x80,0x82..0x8c,0x8e), 'cp1252 encodes most C1 substitutes';
Expand Down

0 comments on commit d422889

Please sign in to comment.