def test_base2base_all_bases(value, expected): for base_in in (2, 8, 16): for base_out in (2, 8, 16): if base_in != base_out: assert compare_result( expected, binary._base2base( value, base_in=base_in, base_out=base_out))
def test_base2base(value, bases, expected): base_in, base_out = bases assert compare_result( expected, binary._base2base(value, base_in=base_in, base_out=base_out)) mapped = { (2, 8): binary.bin2oct, (2, 16): binary.bin2hex, (8, 2): binary.oct2bin, (8, 16): binary.oct2hex, (16, 2): binary.hex2bin, (16, 8): binary.hex2oct, } assert compare_result(expected, mapped[bases](value))
def test_base2base(value, bases, expected): base_in, base_out = bases assert compare_result(expected, binary._base2base( value, base_in=base_in, base_out=base_out)) mapped = { (2, 8): binary.bin2oct, (2, 16): binary.bin2hex, (8, 2): binary.oct2bin, (8, 16): binary.oct2hex, (16, 2): binary.hex2bin, (16, 8): binary.hex2oct, } assert compare_result(expected, mapped[bases](value))
def test_base2base_errors(value): for base_in in (2, 8, 16): for base_out in (2, 8, 16): assert compare_result( value, binary._base2base(value, base_in=base_in, base_out=base_out))
def test_base2base_errors(value): for base_in in (2, 8, 16): for base_out in (2, 8, 16): assert compare_result(value, binary._base2base( value, base_in=base_in, base_out=base_out))