def test_convert_base_simple(): # Quick one-of tests assert _convert_hexstr_base('aaa0111', _ALPHABET_16) == 'aaa0111' assert _convert_hexstr_base('aaa0111', list('01')) == '1010101010100000000100010001' assert _convert_hexstr_base('aaa0111', list('012')) == '110110122202020220' assert _convert_hexstr_base('aaa0111', list('0123')) == '22222200010101' base_10 = list(map(str, range(10))) assert _convert_hexstr_base('aaa0111', base_10) == '178913553'
def test_convert_base_decimal(): base_10 = list(map(str, range(10))) # Test that decimal values agree with python conversion for i in it.chain(range(-10, 10), range(-1000, 1000, 7)): text_16 = hex(i).replace('0x', '') text_10 = _convert_hexstr_base(text_16, base_10) assert int(text_16, 16) == int(text_10, 10)
def test_convert_base_hex(): # Test that hex values are unchanged for i in it.chain(range(-10, 10), range(-1000, 1000, 7)): text = hex(i).replace('0x', '') assert _convert_hexstr_base( text, _ALPHABET_16) == text, ('should not change hex')