# Copyright (c) 2024 Scott Worley # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. import unittest 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.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.check(2112325, ['FIRM', 'COCK']) if __name__ == '__main__': unittest.main()