Exemplo n.º 1
0
 def test_maximum(I):
     'Test the encoder with 0xff.'
     N = 100
     datum = N * [0xff,0xff]
     sut = [byt for byt in base41.B41Encoder(datum)]
     expected = N * [0x41, 0x58, 0x56]   # AXV
     I.assertEqual(sut, expected)
Exemplo n.º 2
0
 def test_minimum(I):
     'Test the encoder with nulls.'
     N = 100
     datum = N * [0, 0]
     sut = [byt for byt in base41.B41Encoder(datum)]
     expected = N * [0x30, 0x30, 0x30]
     I.assertEqual(sut, expected)
Exemplo n.º 3
0
 def test_pair_boundaries(I):
     'Test the encoder on base41 boundaries.'
     data = [
         ([  0,   0], [0x30, 0x30, 0x30]), # 000
         ([  0,  40], [0x58, 0x30, 0x30]), # X00
         ([  0,  41], [0x30, 0x31, 0x30]), # 010
         ([  6, 104], [0x30, 0x58, 0x30]), # 0X0
         ([  6, 144], [0x58, 0x58, 0x30]), # XX0
         ([  6, 145], [0x30, 0x30, 0x31]), # 001
         ([249, 134], [0x30, 0x30, 0x56]), # 00V
         ([255, 238], [0x30, 0x58, 0x56]), # 0XV
         ([255, 255], [0x41, 0x58, 0x56]), # AXV
     ]
     for datum, expected in data:
         sut = [byt for byt in base41.B41Encoder(datum)]
         I.assertEqual(sut, expected)
Exemplo n.º 4
0
 def test_singles(I):
     'Test the encoder using single bytes.'
     for datum, expected in zip(range(41), base41.ALFA):
         sut = [byt for byt in base41.B41Encoder([datum])]
         I.assertEqual(sut, [expected])
Exemplo n.º 5
0
 def test_maximum_trailing(I):
     'Test the encoder with an odd number of 0xff.'
     datum = [0xff,0xff,0xff]
     sut = [byt for byt in base41.B41Encoder(datum)]
     expected = [0x41, 0x58, 0x56, 0x39, 0x36]   # AXV-96
     I.assertEqual(sut, expected)
Exemplo n.º 6
0
 def test_minimum_trailing(I):
     'Test the encoder with an odd number of nulls.'
     datum = [0,0,0]
     sut = [byt for byt in base41.B41Encoder(datum)]
     expected = [0x30, 0x30, 0x30, 0x30]
     I.assertEqual(sut, expected)
Exemplo n.º 7
0
 def test_sanity_hi_trailing(I):
     'Test the encoder with a high trailing byte.'
     datum = b'John)'
     sut = [byt for byt in base41.B41Encoder(datum)]
     expected = [0x4f, 0x6d, 0x6b, 0x32, 0x55, 0x6f, 0x30, 0x31]
     I.assertEqual(sut, expected)
Exemplo n.º 8
0
 def test_sanity(I):
     'Test the encoder with a standard byte string.'
     datum = b'John'
     sut = [byt for byt in base41.B41Encoder(datum)]
     expected = [0x4f, 0x6d, 0x6b, 0x32, 0x55, 0x6f]
     I.assertEqual(sut, expected)