Example #1
0
 def test_convert_binary_to_hexadecimal(self):
     assert convert('1010', 2, 16) == 'a'
     assert convert('1011', 2, 16) == 'b'
     assert convert('1100', 2, 16) == 'c'
     assert convert('1101', 2, 16) == 'd'
     assert convert('1110', 2, 16) == 'e'
     assert convert('1111', 2, 16) == 'f'
     assert convert('1100100001000000', 2, 16) == 'c840'
     assert convert('1101100101010001', 2, 16) == 'd951'
     assert convert('1110101001100010', 2, 16) == 'ea62'
     assert convert('1111101101110011', 2, 16) == 'fb73'
 def test_convert_hexadecimal_to_base_36(self):
     assert convert('5d9f4', 16, 36) == '87w4'
     assert convert('6ff0d1e7', 16, 36) == 'v2578n'
     assert convert('303f5a9203', 16, 36) == '2n7289vn'
     assert convert('3417d7f', 16, 36) == 'wirun'
     assert convert('e91ea3', 16, 36) == '93gdf'
     assert convert('33725b3', 16, 36) == 'w48tv'
     assert convert('3ab1a04a9738', 16, 36) == 'mvirug854'
     assert convert('68a33302c', 16, 36) == 'cwj4758'
     assert convert('243c051afb3', 16, 36) == 'vrw98jw3'
     assert convert('5cdfb7ba', 16, 36) == 'prow56'
Example #3
0
 def test_convert_hexadecimal_to_binary(self):
     assert convert('a', 16, 2) == '1010'
     assert convert('b', 16, 2) == '1011'
     assert convert('c', 16, 2) == '1100'
     assert convert('d', 16, 2) == '1101'
     assert convert('e', 16, 2) == '1110'
     assert convert('f', 16, 2) == '1111'
     assert convert('c840', 16, 2) == '1100100001000000'
     assert convert('d951', 16, 2) == '1101100101010001'
     assert convert('ea62', 16, 2) == '1110101001100010'
     assert convert('fb73', 16, 2) == '1111101101110011'
 def test_convert_base_19_to_base_13(self):
     assert convert('3', 19, 13) == '3'
     assert convert('1edigg', 19, 13) == 'bac234'
     assert convert('1i02ib', 19, 13) == 'ccb324'
     assert convert('1474c0', 19, 13) == '828bcb'
     assert convert('188h5d', 19, 13) == '984520'
     assert convert('9e2g', 19, 13) == '24566'
     assert convert('3b', 19, 13) == '53'
     assert convert('26b11', 19, 13) == 'a9251'
     assert convert('193', 19, 13) == '322'
     assert convert('2aibd3037278', 19, 13) == 'cb73cbaaaaaaa'
 def test_convert_base_36_to_hexadecimal(self):
     assert convert('87w4', 36, 16) == '5d9f4'
     assert convert('v2578n', 36, 16) == '6ff0d1e7'
     assert convert('2n7289vn', 36, 16) == '303f5a9203'
     assert convert('wirun', 36, 16) == '3417d7f'
     assert convert('93gdf', 36, 16) == 'e91ea3'
     assert convert('w48tv', 36, 16) == '33725b3'
     assert convert('mvirug854', 36, 16) == '3ab1a04a9738'
     assert convert('cwj4758', 36, 16) == '68a33302c'
     assert convert('vrw98jw3', 36, 16) == '243c051afb3'
     assert convert('prow56', 36, 16) == '5cdfb7ba'
 def test_convert_base_13_to_base_19(self):
     assert convert('3', 13, 19) == '3'
     assert convert('bac234', 13, 19) == '1edigg'
     assert convert('ccb324', 13, 19) == '1i02ib'
     assert convert('828bcb', 13, 19) == '1474c0'
     assert convert('984520', 13, 19) == '188h5d'
     assert convert('24566', 13, 19) == '9e2g'
     assert convert('53', 13, 19) == '3b'
     assert convert('a9251', 13, 19) == '26b11'
     assert convert('322', 13, 19) == '193'
     assert convert('cb73cbaaaaaaa', 13, 19) == '2aibd3037278'
 def test_convert_binary_to_hexadecimal(self):
     assert convert('1010', 2, 16) == 'A'
     assert convert('1011', 2, 16) == 'B'
     assert convert('1100', 2, 16) == 'C'
     assert convert('1101', 2, 16) == 'D'
     assert convert('1110', 2, 16) == 'E'
     assert convert('1111', 2, 16) == 'F'
     assert convert('1100100001000000', 2, 16) == 'C840'
     assert convert('1101100101010001', 2, 16) == 'D951'
     assert convert('1110101001100010', 2, 16) == 'EA62'
     assert convert('1111101101110011', 2, 16) == 'FB73'
Example #8
0
 def test_convert_decimal_to_hexadecimal(self):
     assert convert('10', 10, 16) == 'a'
     assert convert('15', 10, 16) == 'f'
     assert convert('153', 10, 16) == '99'
     assert convert('255', 10, 16) == 'ff'
     assert convert('2766', 10, 16) == 'ace'
     assert convert('3243', 10, 16) == 'cab'
     assert convert('48813', 10, 16) == 'bead'
     assert convert('64206', 10, 16) == 'face'
     assert convert('12648430', 10, 16) == 'c0ffee'
     assert convert('16435934', 10, 16) == 'facade'
     assert convert('3735928559', 10, 16) == 'deadbeef'
     assert convert('4027038225', 10, 16) == 'f007ba11'
Example #9
0
 def test_convert_hexadecimal_to_decimal(self):
     assert convert('a', 16, 10) == '10'
     assert convert('f', 16, 10) == '15'
     assert convert('99', 16, 10) == '153'
     assert convert('ff', 16, 10) == '255'
     assert convert('ace', 16, 10) == '2766'
     assert convert('cab', 16, 10) == '3243'
     assert convert('bead', 16, 10) == '48813'
     assert convert('face', 16, 10) == '64206'
     assert convert('c0ffee', 16, 10) == '12648430'
     assert convert('facade', 16, 10) == '16435934'
     assert convert('deadbeef', 16, 10) == '3735928559'
     assert convert('f007ba11', 16, 10) == '4027038225'
Example #10
0
 def test_convert_to_binary(self):
     assert convert('111', 3, 2) == '1101'
     assert convert('31', 4, 2) == '1101'
     assert convert('15', 8, 2) == '1101'
     assert convert('13', 10, 2) == '1101'
     assert convert('101', 3, 2) == '1010'
     assert convert('101', 4, 2) == '10001'
     assert convert('101', 8, 2) == '1000001'
     assert convert('101', 10, 2) == '1100101'
     assert convert('101', 16, 2) == '100000001'
     assert convert('101', 25, 2) == '1001110010'
     assert convert('101', 32, 2) == '10000000001'
     assert convert('101', 36, 2) == '10100010001'
Example #11
0
 def test_convert_from_binary(self):
     assert convert('1101', 2, 3) == '111'
     assert convert('1101', 2, 4) == '31'
     assert convert('1101', 2, 8) == '15'
     assert convert('1101', 2, 10) == '13'
     assert convert('101010', 2, 3) == '1120'
     assert convert('101010', 2, 4) == '222'
     assert convert('101010', 2, 8) == '52'
     assert convert('101010', 2, 10) == '42'
     assert convert('101010', 2, 16) == '2a'
     assert convert('101010', 2, 25) == '1h'
     assert convert('101010', 2, 32) == '1a'
     assert convert('101010', 2, 36) == '16'
Example #12
0
    def test_convert(self):
        assert convert('1010', 2, 3) == '101'
        assert convert('1010', 2, 4) == '22'
        assert convert('1010', 2, 8) == '12'
        assert convert('1010', 2, 10) == '10'

        assert convert('101', 3, 2) == '1010'
        assert convert('22', 4, 2) == '1010'
        assert convert('12', 8, 2) == '1010'
        assert convert('10', 10, 2) == '1010'

        assert convert('77', 8, 2) == '111111'
        assert convert('77', 8, 4) == '333'
        assert convert('77', 8, 10) == '63'
        assert convert('77', 8, 16) == '3f'

        assert convert('ff', 16, 2) == '11111111'
        assert convert('ff', 16, 4) == '3333'
        assert convert('ff', 16, 8) == '377'
        assert convert('ff', 16, 10) == '255'
 def test_convert_radix(self):
     assert convert('aafa.ac',16,10) == "43770.672"
     assert convert('9klm1a',32,10) == "323672106"
     assert convert('98', 10,22) == '4a'
 def test_convert_decimal_to_hexadecimal(self):
     assert convert('10', 10, 16) == 'A'
     assert convert('15', 10, 16) == 'F'
     assert convert('153', 10, 16) == '99'
     assert convert('255', 10, 16) == 'FF'
     assert convert('2766', 10, 16) == 'ACE'
     assert convert('3243', 10, 16) == 'CAB'
     assert convert('48813', 10, 16) == 'BEAD'
     assert convert('64206', 10, 16) == 'FACE'
     assert convert('12648430', 10, 16) == 'C0FFEE'
     assert convert('16435934', 10, 16) == 'FACADE'
     assert convert('3735928559', 10, 16) == 'DEADBEEF'
     assert convert('4027038225', 10, 16) == 'F007BA11'
 def test_convert_hexadecimal_to_octal(self):
     assert convert('2e', 16, 8) == '56'
 def test_convert_octal_to_hexadecimal(self):
     assert convert('7674', 8, 16) == 'fbc'
     assert convert('7674', 8, 16) == 'fbc'