def test_encode_string_discarding_unknown(self): set_str = "nnnnnn" cipher = ic.magenta_ornithopter_cipher self.assertEqual("zoot suit frantic bannana quincunx Theodore zoot suit rumble strip rumble strip",\ ic.encode("I am Bill!", cipher, set_str)) self.assertEqual("country mouse undermine the fortifications corncob quality control quincunx frantic bannana fortifications",\ ic.encode("21st of May", cipher, set_str))
def test_encode_string_retaining_unknown_wrapped(self): set_str = "ttnnnn" cipher = ic.magenta_ornithopter_cipher self.assertEqual("corn quality control supervisor rumble strip rumble strip corncob [!]",\ ic.encode("Hello!", cipher, set_str)) self.assertEqual("zoot suit [ ] frantic bannana quincunx [ ] Theodore zoot suit rumble strip rumble strip [!]",\ ic.encode("I am Bill!", cipher, set_str)) self.assertEqual("[2] [1] country mouse undermine the fortifications [ ] corncob quality control [ ] quincunx frantic bannana fortifications",\ ic.encode("21st of May", cipher, set_str)) # don't encode square-bracketed literal passages self.assertEqual("[2] [1] country mouse undermine the fortifications [ ] corncob quality control [fungible hacienda]",\ ic.encode("21st of[fungible hacienda]", cipher, set_str))
def test_encode_string_unwrapping_literals(self): set_str = "tttnnn" cipher = ic.magenta_ornithopter_cipher self.assertEqual("[2] [1] country mouse undermine the fortifications [ ] corncob quality control fungible hacienda",\ ic.encode("21st of[fungible hacienda]", cipher, set_str))
def test_encode_string_simple(self): self.assertEqual("104 101 108 108 111", ic.encode('hello')) self.assertEqual( "corn quality control supervisor rumble strip rumble strip corncob", ic.encode('hello', ic.magenta_ornithopter_cipher))