]> git.scottworley.com Git - rfc1751/blobdiff - rfc1751_test.py
.gitignore __pycache__
[rfc1751] / rfc1751_test.py
index e4c2cd7eb141276a2d85cb5f7bd147c13acfc7e7..a272e89489830118d8fe774c44a8537fbcac5321 100644 (file)
 
 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__':