def test_first_tone(self): s = zhuyin.parse('ㄎㄧㄤ') self.assertEqual(s.initial, 10) self.assertEqual(s.medial, 1) self.assertEqual(s.final, 11) self.assertEqual(s.tone, 1) self.assertFalse(s.er) self.assertEqual(zhuyin.get(s), 'ㄎㄧㄤ')
def test_fifth_tone(self): s = zhuyin.parse('˙ㄇㄚ') self.assertEqual(s.initial, 3) self.assertEqual(s.medial, 0) self.assertEqual(s.final, 1) self.assertEqual(s.tone, 5) self.assertFalse(s.er) self.assertEqual(zhuyin.get(s), '˙ㄇㄚ')
def test_er(self): self.assertEqual(zhuyin.get(zhuyin.parse("ㄔㄨㄦ")), "ㄔㄨㄦ") self.assertEqual(zhuyin.get(zhuyin.parse("˙ㄊㄡㄦ")), "˙ㄊㄡㄦ") self.assertEqual(zhuyin.get(zhuyin.parse("ㄔㄚˊㄦ")), "ㄔㄚˊㄦ") self.assertEqual(zhuyin.get(zhuyin.parse("ㄦˇ")), "ㄦˇ")
def zp(z, p): self.assertEqual(pinyin.get(zhuyin.parse(z)), p)
def test_to_bytes(self): b = to_bytes(zhuyin.parse('ㄎㄧㄤ')) self.assertEqual(len(b), 2) self.assertEqual(b, b'\xb2\x29') # 0b 1011 0010 0010 1001 self.assertEqual(zhuyin.get(from_bytes(b)), 'ㄎㄧㄤ')
def zp(z,p): self.assertEqual(hanyu_pinyin.get(zhuyin.parse(z)),p) self.assertEqual(zhuyin.get(hanyu_pinyin.parse(p)),z)