36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from assembler.util import can_be_mark, can_convert_to_int, autoint
|
|
|
|
|
|
def test_can_be_mark():
|
|
assert can_be_mark("this_is_a_mark") == True
|
|
assert can_be_mark("this_is_a_mark0") == True
|
|
assert can_be_mark("tHIS0") == True
|
|
|
|
assert can_be_mark("This_is_not_a_mark") == False
|
|
assert can_be_mark("0this_is_no_mark") == False
|
|
assert can_be_mark("this#is_no_mark") == False
|
|
|
|
def test_can_convert_to_int():
|
|
assert can_convert_to_int("0xfe") == True
|
|
assert can_convert_to_int("0xFE") == True
|
|
assert can_convert_to_int("10") == True
|
|
assert can_convert_to_int("0b100") == True
|
|
assert can_convert_to_int("'a'") == True
|
|
assert can_convert_to_int("'\\n'") == True
|
|
|
|
|
|
assert can_convert_to_int("0xfg") == False
|
|
assert can_convert_to_int("0xFG") == False
|
|
assert can_convert_to_int("10a") == False
|
|
assert can_convert_to_int("0b20") == False
|
|
assert can_convert_to_int("'aa'") == False
|
|
assert can_convert_to_int("'\\z'") == False
|
|
|
|
def test_autoint():
|
|
assert autoint("0xfe") == 0xfe
|
|
assert autoint("0xFE") == 0xfe
|
|
assert autoint("10") == 10
|
|
assert autoint("0b1010101") == 0b1010101
|
|
assert autoint("'a'") == ord("a")
|
|
assert autoint("'\\n'") == ord("\n")
|