4 class Base32Tests(unittest
.TestCase
):
6 def c(number
: int, pad_to_length
: int, encoded
: str):
7 self
.assertEqual(base32
.encode(number
, pad_to_length
), encoded
)
8 self
.assertEqual(base32
.decode(encoded
), number
)
10 B32_345678
= (1 * 32**5 +
17 B32_base32
= ( 9 * 32**5 +
29 c( 1, 20, '22222222222222222223');
34 c(B32_345678
, 0, '345678');
35 c(B32_base32
, 0, 'base32');
36 c(B32_345678
, 20, '22222222222222345678');
37 c(B32_base32
, 20, '22222222222222base32');
38 c(2**100 - 1, 0, 'zzzzzzzzzzzzzzzzzzzz')
40 # This implementation supports arbitrary length, no truncation.
41 c(1459980823972598128486511383358617792788444579872, 0,
42 'zyxwvutsrqpnmkjihgfedcba98765432')
43 c(0, 1000, '2' * 1000)
44 c(32**1000 - 1, 0, 'z' * 1000)