add unit test asserting that allmydata.util.base32 matches rfc 3548

This commit is contained in:
Zooko O'Whielacronx 2008-02-14 20:20:19 -07:00
parent 3eb95c1fad
commit 5942fca1e1

View File

@ -11,6 +11,14 @@ from allmydata.util import assertutil, fileutil, testutil, deferredutil
class Base32(unittest.TestCase):
def test_b2a_matches_Pythons(self):
import base64
y = "\x12\x34\x45\x67\x89\x0a\xbc\xde\xf0"
x = base64.b32encode(y)
while x and x[-1] == '=':
x = x[:-1]
x = x.lower()
self.failUnlessEqual(base32.b2a(y), x)
def test_b2a(self):
self.failUnlessEqual(base32.b2a("\x12\x34"), "ci2a")
def test_b2a_or_none(self):