Beispiel #1
0
 def test_double_overflow_max(I):
     'Test the decoder detects double byte overflow > 255 (max).'
     datum = [0x28, 0x56]   # (X
     with I.assertRaises(OverflowError) as cm:
         sut = [byt for byt in base41.B41Decoder(datum)]
     I.assertEqual(cm.exception.args[0],
         'decoding two bytes gave a value (1598) greater than 255' )
Beispiel #2
0
 def test_double_underflow(I):
     'Test the decoder detects double byte underflow < 41.'
     datum = [0x58, 0x30]   # X0
     with I.assertRaises(base41.UnderflowError) as cm:
         sut = [byt for byt in base41.B41Decoder(datum)]
     I.assertEqual(cm.exception.args[0],
         'decoding two bytes gave a value (40) less than 41' )
Beispiel #3
0
 def test_triplet_overflow_max(I):
     'Test the decoder detects overflow > 65536.'
     datum = [0x58, 0x58, 0x58]   # X,X,X
     with I.assertRaises(OverflowError) as cm:
         sut = [byt for byt in base41.B41Decoder(datum)]
     I.assertEqual(cm.exception.args[0],
         'decoding three bytes gave a value (68920) greater than 65535' )
Beispiel #4
0
 def test_double_overflow_alt(I):
     'Test the decoder detects double byte overflow > 255 (alt chars).'
     datum = [0x3a, 0x66]   # :f
     with I.assertRaises(OverflowError) as cm:
         sut = [byt for byt in base41.B41Decoder(datum)]
     I.assertEqual(cm.exception.args[0],
         'decoding two bytes gave a value (256) greater than 255' )
Beispiel #5
0
 def test_maximum(I):
     'Test the decoder with 0xff.'
     N = 100
     datum = N * [0x41, 0x58, 0x56]   # AXV
     sut = [byt for byt in base41.B41Decoder(datum)]
     expected = N * [0xff,0xff]
     I.assertEqual(sut, expected)
Beispiel #6
0
 def test_triplet_overflow_alt(I):
     'Test the decoder detects overflow > 65536 (alternative chars).'
     datum = [0x72, 0x28, 0x26]   # r(&
     with I.assertRaises(OverflowError) as cm:
         sut = [byt for byt in base41.B41Decoder(datum)]
     I.assertEqual(cm.exception.args[0],
         'decoding three bytes gave a value (65536) greater than 65535' )
Beispiel #7
0
 def test_minimum(I):
     'Test the decoder with nulls.'
     N = 100
     datum = N * [0x30, 0x30, 0x30]
     sut = [byt for byt in base41.B41Decoder(datum)]
     expected = N * [0, 0]
     I.assertEqual(sut, expected)
Beispiel #8
0
 def test_pair_boundaries(I):
     'Test the decoder 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 expected, datum in data:
         sut = [byt for byt in base41.B41Decoder(datum)]
         I.assertEqual(sut, expected)
Beispiel #9
0
 def test_singles(I):
     'Test the decoder using single bytes.'
     for datum, expected in zip(base41.ALFA, range(41)):
         sut = [byt for byt in base41.B41Decoder([datum])]
         I.assertEqual(sut, [expected])
Beispiel #10
0
 def test_maximum_trailing(I):
     'Test the decoder with an odd number of 0xff.'
     datum = [0x41, 0x58, 0x56, 0x39, 0x36]   # AXV-96
     sut = [byt for byt in base41.B41Decoder(datum)]
     expected = [0xff,0xff,0xff]
     I.assertEqual(sut, expected)
Beispiel #11
0
 def test_minimum_trailing(I):
     'Test the decoder with an odd number of nulls.'
     datum = [0x30, 0x30, 0x30, 0x30]
     sut = [byt for byt in base41.B41Decoder(datum)]
     expected = [0,0,0]
     I.assertEqual(sut, expected)
Beispiel #12
0
 def test_sanity_hi_trailing(I):
     'Test the decoder with a high trailing byte.'
     datum = [0x4f, 0x6d, 0x6b, 0x32, 0x55, 0x6f, 0x30, 0x31]
     sut = [byt for byt in base41.B41Decoder(datum)]
     expected = [0x4a, 0x6f, 0x68, 0x6e, 0x29]
     I.assertEqual(sut, expected)
Beispiel #13
0
 def test_sanity(I):
     'Test the decoder with a standard byte string.'
     datum = [0x4f, 0x6d, 0x6b, 0x32, 0x55, 0x6f]
     sut = [byt for byt in base41.B41Decoder(datum)]
     expected = [0x4a, 0x6f, 0x68, 0x6e]
     I.assertEqual(sut, expected)