def test_apply(self): f = NumberFormula() for k in list(self.testDict.keys()): # print "--> Testing %s " % k testList = self.testDict[k] self.evaluateListValues(testList, f.apply)
def test_normalizeNumber(self): testList = [(u"2,5",u"25"), # Notation error, comma is for thousand (u"123,",u"123"), (u"123.",u"123"), (u"50,000",u"50000"),(u"550,000,000",u"550000000"),(u"1,416,000",u"1416000")] for t, gt in testList: self.assertEquals(NumberFormula._normalizeNumber(t), gt, t.encode('utf-8'))
def test_normalizeNumber(self): testList = [ ("2,5", "25"), # Notation error, comma is for thousand ("123,", "123"), ("123.", "123"), ("50,000", "50000"), ("550,000,000", "550000000"), ("1,416,000", "1416000") ] for t, gt in testList: self.assertEqual(NumberFormula._normalizeNumber(t), gt, t)
def test_isDecimal(self): testList = [("2.5", True), ("2,5", False), ("2.5,3", False), ("2-5", False)] for t, gt in testList: self.assertEqual(NumberFormula._isDecimalNumber(t), gt, t)
def test_isOrdinal(self): testList = [("1st", True), ("2nd", True), ("3rd", True), ("4th", True)] for t, gt in testList: self.assertEqual(NumberFormula._isOrdinalNumber(t), gt, t)
def test_isTransition(self): testList = [("1.", True), ("10.", True), ("11.", False)] for t, gt in testList: self.assertEqual(NumberFormula._isTransitionNumber(t), gt, t)
def test_isCardinal(self): testList = [("2", True), ("123", True), ("123.", False)] for t, gt in testList: self.assertEqual(NumberFormula._isCardinalNumber(t), gt, t)
def test_ordinal2word(self): testList = self.testDict["ordinal"] for i, (t, gt) in enumerate(testList): r = NumberFormula._ordinal2word([t], 0) self.assertEqual(gt, r, "%s is not %s" % (r, gt))
def test_isRoman(self): testList = [("LV", True), ("XII", True), ("La", False)] for t, gt in testList: self.assertEqual(NumberFormula._isRomanNumber(t), gt, t)
def test_isRoman(self): testList = [(u"LV",True), (u"XII",True), (u"La", False)] for t, gt in testList: self.assertEquals(NumberFormula._isRomanNumber(t), gt, t.encode('utf-8'))
def test_isDecimal(self): testList = [(u"2.5",True), (u"2,5",False),(u"2.5,3",False), (u"2-5",False)] for t, gt in testList: self.assertEquals(NumberFormula._isDecimalNumber(t), gt, t.encode('utf-8'))
def test_isOrdinal(self): testList = [(u"1st",True),(u"2nd",True),(u"3rd",True),(u"4th",True)] for t, gt in testList: self.assertEquals(NumberFormula._isOrdinalNumber(t), gt, t.encode('utf-8'))
def test_isTransition(self): testList = [(u"1.",True),(u"10.",True), (u"11.",False)] for t, gt in testList: self.assertEquals(NumberFormula._isTransitionNumber(t), gt, t.encode('utf-8'))
def test_isCardinal(self): testList = [(u"2",True),(u"123",True), (u"123.",False)] for t, gt in testList: self.assertEquals(NumberFormula._isCardinalNumber(t), gt, t.encode('utf-8'))
def test_ordinal2word(self): testList = self.testDict["ordinal"] for i, (t, gt) in enumerate(testList): r = NumberFormula._ordinal2word([t], 0) self.assertEquals(gt.encode('utf-8'), r.encode('utf-8'), "%s is not %s" % (r.encode('utf-8'), gt.encode('utf-8')))