Skip to content

Commit

Permalink
Adds test (Windows only) to Str.encode
Browse files Browse the repository at this point in the history
Since that option is only available in Windows, I have added that test
with the optional code. Closes #459
  • Loading branch information
JJ committed Aug 8, 2018
1 parent 972e25a commit 4d472c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion S32-str/encode.t
Expand Up @@ -11,7 +11,13 @@ 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, 4, 'right length of Buf';
ok 'a\nb'.encode('utf8') eqv utf8.new(97,0x5c,0x6e,98), 'Non-translation of \n';

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

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 4d472c9

Please sign in to comment.