tests: Add test of invalid unicode strings.
.. from non UTF-8 inputs. In this case, MicroPython raises UnicodeError while CPython uses SyntaxError. By catching either exception, the test does not require an .exp file. Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit is contained in:
parent
1588c455c4
commit
90012e7d6a
1 changed files with 23 additions and 0 deletions
23
tests/unicode/unicode_parser.py
Normal file
23
tests/unicode/unicode_parser.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# test invalid UTF-8 string via eval
|
||||
# Passing byte strings to exec/eval is a micropython extension
|
||||
try:
|
||||
eval(b"'ab\xa1'")
|
||||
except SyntaxError:
|
||||
print("Exception")
|
||||
try:
|
||||
eval(b"'ab\xf8'")
|
||||
except SyntaxError:
|
||||
print("Exception")
|
||||
try:
|
||||
eval(bytearray(b"'ab\xc0a'"))
|
||||
except SyntaxError:
|
||||
print("Exception")
|
||||
try:
|
||||
eval(b"'\xf0\xe0\xed\xe8'")
|
||||
except SyntaxError:
|
||||
print("Exception")
|
||||
|
||||
try:
|
||||
exec(b"b\xff = 1")
|
||||
except SyntaxError:
|
||||
print("Exception")
|
||||
Loading…
Reference in a new issue