diff --git a/num2words/base.py b/num2words/base.py index 243045ff..0bccbe60 100644 --- a/num2words/base.py +++ b/num2words/base.py @@ -39,7 +39,8 @@ def __init__(self): self.errmsg_floatord = "Cannot treat float %s as ordinal." self.errmsg_negord = "Cannot treat negative num %s as ordinal." self.errmsg_toobig = "abs(%s) must be less than %s." - + self.cards = OrderedDict() + self.MAXVAL = None self.setup() # uses cards @@ -111,7 +112,7 @@ def to_cardinal(self, value): value = abs(value) out = "%s " % self.negword.strip() - if value >= self.MAXVAL: + if self.MAXVAL and value >= self.MAXVAL: raise OverflowError(self.errmsg_toobig % (value, self.MAXVAL)) val = self.splitnum(value) diff --git a/num2words/lang_AR.py b/num2words/lang_AR.py index 7195dd47..bbebe20a 100644 --- a/num2words/lang_AR.py +++ b/num2words/lang_AR.py @@ -347,7 +347,7 @@ def convert_to_arabic(self): return formatted_number def validate_number(self, number): - if number >= self.MAXVAL: + if self.MAXVAL and number >= self.MAXVAL: raise OverflowError(self.errmsg_toobig % (number, self.MAXVAL)) return number diff --git a/num2words/lang_ID.py b/num2words/lang_ID.py index 54e636f9..3cc2673a 100644 --- a/num2words/lang_ID.py +++ b/num2words/lang_ID.py @@ -169,7 +169,7 @@ def join(self, word_blocks, float_part): return ' '.join(word_list) + float_part def to_cardinal(self, number): - if number >= self.MAXVAL: + if self.MAXVAL and number >= self.MAXVAL: raise OverflowError(self.errmsg_toobig % (number, self.MAXVAL)) minus = '' if number < 0: diff --git a/tests/test_base.py b/tests/test_base.py index efa1bc81..e05bc7df 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -62,3 +62,16 @@ def test_is_title(self): self.base.title("one"), "one" ) + + def test_set_high_numwords_not_implemented(self): + with self.assertRaises(NotImplementedError): + self.base.set_high_numwords() + + def test_to_ordinal(self): + from num2words.base import Num2Word_Base + self.base = Num2Word_Base() + self.assertEqual(self.base.to_ordinal(1), "1st") + self.assertEqual(self.base.to_ordinal(11), "11th") + self.assertEqual(self.base.to_ordinal(21), "21st") + self.assertEqual(self.base.to_ordinal(100), "100th") + self.assertEqual(self.base.to_ordinal(123), "123rd")