Permalink
Please sign in to comment.
Browse files
Do utf-8 encoding of \u1234 in pure Python.
We want to remove the dependency on Python unicode objects. Co-authored-by: Emanuel Geromin <egeromin@users.noreply.github.com>
- Loading branch information...
Showing
with
70 additions
and 3 deletions.
- +34 −1 core/word_compile.py
- +29 −0 core/word_compile_test.py
- +1 −0 native/libc_test.py
- +6 −2 spec/builtin-io.test.sh
| @@ -0,0 +1,29 @@ | ||
| #!/usr/bin/python -S | ||
| """ | ||
| word_compile_test.py: Tests for word_compile.py | ||
| """ | ||
| import unittest | ||
| from core import word_compile # module under test | ||
| class WordCompileTest(unittest.TestCase): | ||
| def testUtf8Encode(self): | ||
| CASES = [ | ||
| (u'\u0065'.encode('utf-8'), 0x0065), | ||
| (u'\u0100'.encode('utf-8'), 0x0100), | ||
| (u'\u1234'.encode('utf-8'), 0x1234), | ||
| (u'\U00020000'.encode('utf-8'), 0x00020000), | ||
| # Out of range gives Unicode replacement character. | ||
| ('\xef\xbf\xbd', 0x10020000), | ||
| ] | ||
| for expected, code_point in CASES: | ||
| print('') | ||
| print('Utf8Encode case %r %r' % (expected, code_point)) | ||
| self.assertEqual(expected, word_compile.Utf8Encode(code_point)) | ||
| if __name__ == '__main__': | ||
| unittest.main() |
0 comments on commit
4f19662