X-Git-Url: http://git.scottworley.com/rfc1751/blobdiff_plain/06b69e2e270101769bd17e2884d30033d09a7892..799dace08ed7ffca0b94c4b8c21472f71e42f574:/rfc1751_test.py?ds=inline diff --git a/rfc1751_test.py b/rfc1751_test.py index e4c2cd7..a272e89 100644 --- a/rfc1751_test.py +++ b/rfc1751_test.py @@ -15,21 +15,25 @@ import unittest -from rfc1751 import rfc1751 +from rfc1751 import encode, decode class TestRFC1751(unittest.TestCase): + def check(self, num: int, words: list[str]) -> None: + self.assertEqual(encode(num), words) + self.assertEqual(decode(words), num) + def testRFC1751(self) -> None: - self.assertEqual(rfc1751(0), ['A']) - self.assertEqual(rfc1751(1), ['ABE']) - self.assertEqual(rfc1751(2), ['ACE']) - self.assertEqual(rfc1751(2047), ['YOKE']) - self.assertEqual(rfc1751(2048), ['ABE', 'A']) - self.assertEqual(rfc1751(2049), ['ABE', 'ABE']) - self.assertEqual(rfc1751(2050), ['ABE', 'ACE']) + self.check(0, ['A']) + self.check(1, ['ABE']) + self.check(2, ['ACE']) + self.check(2047, ['YOKE']) + self.check(2048, ['ABE', 'A']) + self.check(2049, ['ABE', 'ABE']) + self.check(2050, ['ABE', 'ACE']) # Note: These can get NSFW - self.assertEqual(rfc1751(2112325), ['FIRM', 'COCK']) + self.check(2112325, ['FIRM', 'COCK']) if __name__ == '__main__':