예제 #1
0
 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), 'ㄎㄧㄤ')
예제 #2
0
 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), '˙ㄇㄚ')
예제 #3
0
 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("ㄦˇ")), "ㄦˇ")
예제 #4
0
 def zp(z, p):
     self.assertEqual(pinyin.get(zhuyin.parse(z)), p)
예제 #5
0
 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)), 'ㄎㄧㄤ')
예제 #6
0
 def zp(z,p):
     self.assertEqual(hanyu_pinyin.get(zhuyin.parse(z)),p)
     self.assertEqual(zhuyin.get(hanyu_pinyin.parse(p)),z)