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_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_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 test_pinyin_number(self): self.assertEqual(zhuyin.get(pinyin_number.parse('yi1')), 'ㄧ') self.assertEqual(zhuyin.get(pinyin_number.parse('Yi1')), 'ㄧ')
def test_propernoun_pinyin(self): # whether or not the syllable is capitalized is not stored yet. self.assertEqual(zhuyin.get(pinyin.parse('Yī')), 'ㄧ')
def zp(z, p): self.assertEqual(pinyin.get(zhuyin.parse(z)), p) self.assertEqual(zhuyin.get(pinyin.parse(p)), z)
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)), 'ㄎㄧㄤ')