Commit c15ebf7c authored by Rami Ali's avatar Rami Ali Committed by Damien George
Browse files

tests/extmod: Improve ubinascii.c test coverage.

parent 45a8cc8f
...@@ -14,6 +14,7 @@ print(binascii.a2b_base64(b'Zm9vYmFy')) ...@@ -14,6 +14,7 @@ print(binascii.a2b_base64(b'Zm9vYmFy'))
print(binascii.a2b_base64(b'AAECAwQFBgc=')) print(binascii.a2b_base64(b'AAECAwQFBgc='))
print(binascii.a2b_base64(b'CAkKCwwNDg8=')) print(binascii.a2b_base64(b'CAkKCwwNDg8='))
print(binascii.a2b_base64(b'f4D/')) print(binascii.a2b_base64(b'f4D/'))
print(binascii.a2b_base64(b'f4D+')) # convert '+'
print(binascii.a2b_base64(b'MTIzNEFCQ0RhYmNk')) print(binascii.a2b_base64(b'MTIzNEFCQ0RhYmNk'))
try: try:
......
...@@ -15,3 +15,4 @@ print(binascii.b2a_base64(b'\x00\x01\x02\x03\x04\x05\x06\x07')) ...@@ -15,3 +15,4 @@ print(binascii.b2a_base64(b'\x00\x01\x02\x03\x04\x05\x06\x07'))
print(binascii.b2a_base64(b'\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f')) print(binascii.b2a_base64(b'\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'))
print(binascii.b2a_base64(b'\x7f\x80\xff')) print(binascii.b2a_base64(b'\x7f\x80\xff'))
print(binascii.b2a_base64(b'1234ABCDabcd')) print(binascii.b2a_base64(b'1234ABCDabcd'))
print(binascii.b2a_base64(b'\x00\x00>')) # convert into '+'
try:
import ubinascii as binascii
except ImportError:
import binascii
# two arguments supported in uPy but not CPython
a = binascii.hexlify(b'123', ':')
print(a)
...@@ -7,3 +7,13 @@ print(binascii.unhexlify(b'0001020304050607')) ...@@ -7,3 +7,13 @@ print(binascii.unhexlify(b'0001020304050607'))
print(binascii.unhexlify(b'08090a0b0c0d0e0f')) print(binascii.unhexlify(b'08090a0b0c0d0e0f'))
print(binascii.unhexlify(b'7f80ff')) print(binascii.unhexlify(b'7f80ff'))
print(binascii.unhexlify(b'313233344142434461626364')) print(binascii.unhexlify(b'313233344142434461626364'))
try:
a = binascii.unhexlify(b'0') # odd buffer length
except ValueError:
print('ValueError')
try:
a = binascii.unhexlify(b'gg') # digit not hex
except ValueError:
print('ValueError')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment