def test_encode_valid_char(self): self.assertEqual('119', ic.encode_char('w')) self.assertEqual('mortification of the flesh',\ ic.encode_char('w', ic.magenta_ornithopter_cipher)) self.assertEqual('119', ic.encode_char('W')) self.assertEqual('mortification of the flesh',\ ic.encode_char('W', ic.magenta_ornithopter_cipher))
def test_encode_digits_are_unknown_chars(self): sett = [False, False, False, False, False, False] self.assertEqual(None, ic.encode_char('2', settings=sett)) self.assertEqual(None, ic.encode_char('0', settings=sett)) sett = [True, False, False, False, False, False] self.assertEqual('0', ic.encode_char('0', settings=sett)) self.assertEqual('4', ic.encode_char('4', settings=sett)) sett = [True, True, False, False, False, False] self.assertEqual('[9]', ic.encode_char('9', settings=sett)) self.assertEqual('[6]', ic.encode_char('6', settings=sett)) # this is the default setting self.assertEqual('[6]', ic.encode_char('6'))
def test_encode_unknown_char_retained_wrapped(self): sett = [True, True, False, False, False, False] self.assertEqual('[&]', ic.encode_char('&', settings=sett)) self.assertEqual('[^]', ic.encode_char('^', settings=sett)) self.assertEqual('[balls]', ic.encode_char('balls', settings=sett))
def test_encode_unknown_char_discarded(self): sett = [False, False, False, False, False, False] self.assertEqual(None, ic.encode_char('&', settings=sett)) self.assertEqual(None, ic.encode_char('^)', settings=sett)) self.assertEqual(None, ic.encode_char('balls', settings=sett))