X-Git-Url: http://git.scottworley.com/rfc1751/blobdiff_plain/1cfbde798b119a1678a7941d3702f52018f7e857..c4374da5ae0994f0ca5e2e243e5577199267d985:/rfc1751_test.py?ds=sidebyside diff --git a/rfc1751_test.py b/rfc1751_test.py index 9999dac..a272e89 100644 --- a/rfc1751_test.py +++ b/rfc1751_test.py @@ -15,21 +15,25 @@ import unittest -from rfc1751 import encode +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(encode(0), ['A']) - self.assertEqual(encode(1), ['ABE']) - self.assertEqual(encode(2), ['ACE']) - self.assertEqual(encode(2047), ['YOKE']) - self.assertEqual(encode(2048), ['ABE', 'A']) - self.assertEqual(encode(2049), ['ABE', 'ABE']) - self.assertEqual(encode(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(encode(2112325), ['FIRM', 'COCK']) + self.check(2112325, ['FIRM', 'COCK']) if __name__ == '__main__':