Пример #1
0
 def test_encode_into_1010(self):
     assert encode(10, 2) == '1010'
     assert encode(68, 4) == '1010'
     assert encode(520, 8) == '1010'
     assert encode(1010, 10) == '1010'
     assert encode(4112, 16) == '1010'
     assert encode(15650, 25) == '1010'
     assert encode(32800, 32) == '1010'
     assert encode(46692, 36) == '1010'
Пример #2
0
 def test_encode_into_10(self):
     assert encode(2, 2) == '10'
     assert encode(4, 4) == '10'
     assert encode(8, 8) == '10'
     assert encode(10, 10) == '10'
     assert encode(16, 16) == '10'
     assert encode(25, 25) == '10'
     assert encode(32, 32) == '10'
     assert encode(36, 36) == '10'
Пример #3
0
 def test_encode_248975(self):
     assert encode(248975, 2) == '111100110010001111'
     assert encode(248975, 4) == '330302033'
     assert encode(248975, 8) == '746217'
     assert encode(248975, 10) == '248975'
     assert encode(248975, 16) == '3cc8f'
     assert encode(248975, 25) == 'fn90'
     assert encode(248975, 32) == '7j4f'
     assert encode(248975, 36) == '5c3z'
Пример #4
0
 def test_encode_1234(self):
     assert encode(1234, 2) == '10011010010'
     assert encode(1234, 3) == '1200201'
     assert encode(1234, 4) == '103102'
     assert encode(1234, 5) == '14414'
     assert encode(1234, 8) == '2322'
     assert encode(1234, 10) == '1234'
     assert encode(1234, 16) == '4d2'
     assert encode(1234, 32) == '16i'
Пример #5
0
 def test_encode_binary(self):
     # assert encode(0, 2) == '0'  # Should '' be valid?
     assert encode(1, 2) == '1'
     assert encode(2, 2) == '10'
     assert encode(3, 2) == '11'
     assert encode(4, 2) == '100'
     assert encode(5, 2) == '101'
     assert encode(6, 2) == '110'
     assert encode(7, 2) == '111'
     assert encode(8, 2) == '1000'
     assert encode(9, 2) == '1001'
     assert encode(10, 2) == '1010'
     assert encode(11, 2) == '1011'
     assert encode(12, 2) == '1100'
     assert encode(13, 2) == '1101'
     assert encode(14, 2) == '1110'
     assert encode(15, 2) == '1111'
Пример #6
0
 def test_encode_hexadecimal(self):
     assert encode(10, 16) == 'a'
     assert encode(15, 16) == 'f'
     assert encode(153, 16) == '99'
     assert encode(255, 16) == 'ff'
     assert encode(2766, 16) == 'ace'
     assert encode(3243, 16) == 'cab'
     assert encode(48813, 16) == 'bead'
     assert encode(64206, 16) == 'face'
     assert encode(12648430, 16) == 'c0ffee'
     assert encode(16435934, 16) == 'facade'
     assert encode(3735928559, 16) == 'deadbeef'
     assert encode(4027038225, 16) == 'f007ba11'
Пример #7
0
 def test_encode_decimal(self):
     # assert encode(0, 10) == '0'  # Should '' be valid?
     assert encode(5, 10) == '5'
     assert encode(10, 10) == '10'
     assert encode(25, 10) == '25'
     assert encode(64, 10) == '64'
     assert encode(99, 10) == '99'
     assert encode(123, 10) == '123'
     assert encode(789, 10) == '789'
     assert encode(2345, 10) == '2345'
     assert encode(6789, 10) == '6789'
     assert encode(13579, 10) == '13579'
     assert encode(24680, 10) == '24680'