1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
# encoding: utf-8
import os
import sys
import unittest
import tomoe
class TomoeReadingTest(unittest.TestCase):
def testDuplicate(self):
for type in (tomoe.READING_INVALID, tomoe.READING_UNKNOWN, tomoe.READING_JA_KUN, tomoe.READING_JA_ON):
reading_string = 'いけ'
reading1 = tomoe.Reading(type, reading_string)
reading2 = reading1.dup()
self.assertEqual(type, reading2.get_reading_type())
self.assertEqual(reading_string, reading2.get_reading())
def testGetReadingType(self):
reading_string = "いけ"
reading = tomoe.Reading(tomoe.READING_INVALID, reading_string)
self.assertEqual(tomoe.READING_INVALID, reading.get_reading_type())
reading = tomoe.Reading(tomoe.READING_UNKNOWN, reading_string)
self.assertEqual(tomoe.READING_UNKNOWN, reading.get_reading_type())
reading = tomoe.Reading(tomoe.READING_JA_KUN, reading_string)
self.assertEqual(tomoe.READING_JA_KUN, reading.get_reading_type())
reading = tomoe.Reading(tomoe.READING_JA_ON, reading_string)
self.assertEqual(tomoe.READING_JA_ON, reading.get_reading_type())
def testGetReading(self):
reading_string = "いけ"
reading = tomoe.Reading(tomoe.READING_UNKNOWN, reading_string)
self.assertEqual(reading_string, reading.get_reading())
def testToXML(self):
reading_string = "いけ"
reading = tomoe.Reading(tomoe.READING_UNKNOWN, reading_string)
reading_data = """\
<reading type="unknown">%s</reading>
""" % (reading_string)
self.assertEqual(reading_data, reading.to_xml())
def testCompare(self):
reading_string = "いけ"
reading_string2 = "ほげ"
reading1 = tomoe.Reading(tomoe.READING_UNKNOWN, reading_string)
reading2 = tomoe.Reading(tomoe.READING_UNKNOWN, reading_string)
reading3 = tomoe.Reading(tomoe.READING_UNKNOWN, reading_string2)
self.assertEqual(reading1, reading2)
self.assertNotEqual(reading1, reading3)
reading1 = tomoe.Reading(tomoe.READING_JA_KUN, reading_string)
reading2 = tomoe.Reading(tomoe.READING_UNKNOWN, reading_string)
reading3 = tomoe.Reading(tomoe.READING_JA_KUN, reading_string2)
reading4 = tomoe.Reading(tomoe.READING_UNKNOWN, reading_string2)
self.assertEqual(reading1, reading2)
self.assertNotEqual(reading2, reading3)
self.assertNotEqual(reading1, reading4)
reading1 = tomoe.Reading(tomoe.READING_JA_ON, reading_string)
reading2 = tomoe.Reading(tomoe.READING_UNKNOWN, reading_string)
reading3 = tomoe.Reading(tomoe.READING_JA_ON, reading_string2)
reading4 = tomoe.Reading(tomoe.READING_UNKNOWN, reading_string2)
self.assertEqual(reading1, reading2)
self.assertNotEqual(reading2, reading3)
self.assertNotEqual(reading1, reading4)
reading1 = tomoe.Reading(tomoe.READING_JA_ON, reading_string)
reading2 = tomoe.Reading(tomoe.READING_JA_ON, reading_string)
reading3 = tomoe.Reading(tomoe.READING_JA_ON, reading_string2)
self.assertEqual(reading1, reading2)
self.assertNotEqual(reading1, reading3)
reading1 = tomoe.Reading(tomoe.READING_JA_KUN, reading_string)
reading2 = tomoe.Reading(tomoe.READING_JA_KUN, reading_string)
reading3 = tomoe.Reading(tomoe.READING_JA_KUN, reading_string2)
self.assertEqual(reading1, reading2)
self.assertNotEqual(reading1, reading3)
reading1 = tomoe.Reading(tomoe.READING_JA_ON, reading_string)
reading2 = tomoe.Reading(tomoe.READING_JA_KUN, reading_string)
reading3 = tomoe.Reading(tomoe.READING_JA_ON, reading_string2)
reading4 = tomoe.Reading(tomoe.READING_JA_KUN, reading_string2)
self.assertNotEqual(reading1, reading2)
self.assertNotEqual(reading2, reading3)
self.assertNotEqual(reading1, reading4)
# vi:ts=4:nowrap:ai:expandtab
|