diff --git a/README.rst b/README.rst index 9b1e97f6..3c6cd289 100644 --- a/README.rst +++ b/README.rst @@ -121,6 +121,7 @@ Besides the numerical argument, there are two main optional arguments, ``to:`` a * ``ro`` (Romanian) * ``ru`` (Russian) * ``te`` (Telugu) +* ``tet`` (Tetum) * ``tg`` (Tajik) * ``tr`` (Turkish) * ``th`` (Thai) diff --git a/num2words/__init__.py b/num2words/__init__.py index 43616cce..6b39b4f4 100644 --- a/num2words/__init__.py +++ b/num2words/__init__.py @@ -24,8 +24,8 @@ lang_FR_CH, lang_FR_DZ, lang_HE, lang_HU, lang_ID, lang_IS, lang_IT, lang_JA, lang_KN, lang_KO, lang_KZ, lang_LT, lang_LV, lang_NL, lang_NO, lang_PL, lang_PT, lang_PT_BR, lang_RO, - lang_RU, lang_SK, lang_SL, lang_SR, lang_SV, lang_TE, lang_TG, - lang_TH, lang_TR, lang_UK, lang_VI) + lang_RU, lang_SK, lang_SL, lang_SR, lang_SV, lang_TE, lang_TET, + lang_TG, lang_TH, lang_TR, lang_UK, lang_VI) CONVERTER_CLASSES = { 'am': lang_AM.Num2Word_AM(), @@ -80,6 +80,7 @@ 'nl': lang_NL.Num2Word_NL(), 'uk': lang_UK.Num2Word_UK(), 'te': lang_TE.Num2Word_TE(), + 'tet': lang_TET.Num2Word_TET(), 'hu': lang_HU.Num2Word_HU(), 'is': lang_IS.Num2Word_IS(), } diff --git a/num2words/lang_TET.py b/num2words/lang_TET.py new file mode 100644 index 00000000..141a8c66 --- /dev/null +++ b/num2words/lang_TET.py @@ -0,0 +1,251 @@ +# -*- coding: utf-8 -*-Num2Word_TET +# Copyright (c) 2003, Taro Ogawa. All Rights Reserved. +# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved. + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301 USA + + +from num2words.currency import parse_currency_parts + +from .lang_EU import Num2Word_EU + +DOLLAR = ('dolar', 'dolar') +CENTS = ('sentavu', 'sentavu') + + +class Num2Word_TET(Num2Word_EU): + + CURRENCY_FORMS = { + 'AUD': (DOLLAR, CENTS), + 'CAD': (DOLLAR, CENTS), + 'EUR': (('euro', 'euros'), CENTS), + 'GBP': (('pound sterling', 'pound sterling'), ('pence', 'pence')), + 'USD': (DOLLAR, CENTS), + } + + GIGA_SUFFIX = None + MEGA_SUFFIX = "iliaun" + + def setup(self): + super().setup() + lows = ["kuatr", "tr", "b", "m"] + self.high_numwords = self.gen_high_numwords([], [], lows) + self.negword = "menus " + self.pointword = "vírgula" + self.exclude_title = ["resin", "vírgula", "menus"] + self.count = 0 + + self.mid_numwords = [ + (1000, "rihun"), (100, "atus"), (90, "sianulu"), + (80, "ualunulu"), (70, "hitunulu"), (60, "neenulu"), + (50, "limanulu"), (40, "haatnulu"), (30, "tolunulu"), + (20, "ruanulu") + ] + self.low_numwords = [ + "sanulu", + "sia", "ualu", "hitu", "neen", "lima", "haat", "tolu", "rua", + "ida", "mamuk" + ] + self.hundreds = { + 1: "atus", + 2: "atus rua", + 3: "atus tolu", + 4: "atus haat", + 5: "atus lima", + 6: "atus neen", + 7: "atus hitu", + 8: "atus ualu", + 9: "atus sia", + } + + def merge(self, curr, next): + ctext, cnum, ntext, nnum = curr + next + + if cnum == 1 and nnum < 100: + return next + + if nnum < cnum: + if nnum < 10: + value_str = str(cnum + nnum) + if int(value_str) > 100: + zero_list = value_str[1:-1] + all_zero = all(element == '0' for element in zero_list) + if all_zero: + if self.count >= 1: + self.count += 0 + return ( + "ho %s %s" % (ctext, ntext), + cnum + nnum + ) + self.count += 1 + return ("%s %s" % (ctext, ntext), cnum + nnum) + + return ("%s resin %s" % (ctext, ntext), cnum + nnum) + else: + return ("%s %s" % (ctext, ntext), cnum + nnum) + + return (ntext + " " + ctext, cnum * nnum) + + def ho_result(self, result, value): + index = result.find('ho') + count_ho = result.count('ho') + + if index != -1 and count_ho >= 1: + index_rihun = result.find('rihun') + value_str = len(str(value)) + if index_rihun != -1 and value_str > 7: + result = result.replace("rihun ho", "ho rihun") + lows = ["kuatr", "tr", "b", "m"] + MEGA_SUFFIX = "iliaun" + for low in lows: + result = result.replace( + low + MEGA_SUFFIX + " ho", "ho " + low + MEGA_SUFFIX) + remove_first_ho = result.startswith('ho') + if remove_first_ho: + result = result[3:] + return result + + def remove_ho(self, result, value): + value_str = str(value) + result = self.ho_result(result, value) + end_value = value_str[:-4] + end_true = end_value.endswith('0') + if end_true is False: + if value > 100: + if value_str[-1] != '0' and value_str[-2] == '0': + result = result.replace("ho", "") + result = result.replace(" ", " ") + + return result + + def to_cardinal(self, value): + result = super().to_cardinal(value) + + results = self.remove_ho(result, value) + return results + + def to_ordinal(self, value): + self.verify_ordinal(value) + out = "" + val = self.splitnum(value) + outs = val + while len(val) != 1: + outs = [] + left, right = val[:2] + if isinstance(left, tuple) and isinstance(right, tuple): + outs.append(self.merge(left, right)) + if val[2:]: + outs.append(val[2:]) + else: + for elem in val: + if isinstance(elem, list): + if len(elem) == 1: + outs.append(elem[0]) + else: + outs.append(self.clean(elem)) + else: + outs.append(elem) + val = outs + + words, num = outs[0] + + words = self.remove_ho(words, value) + + if num in [90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 5, 3, 2]: + words = 'da'+words+'k' + if num in [6, 4]: + words = 'da'+words + if num == 1: + words = 'dahuluk' + if num in [900, 800, 700, 500, 300, 200, 100]: + words = 'dah'+words+'k' + if num in [600, 400]: + words = 'dah'+words + + words_split = words.split() + if len(words_split) >= 3 and num < 100: + first_word = 'da'+words_split[0] + second_word = " ".join(words_split[1:]) + if 'haat' in second_word or 'neen' in second_word: + words = first_word+" "+second_word + else: + words = first_word+" "+second_word+'k' + + word_first = 'dah'+words_split[0] + if word_first == 'dahatus' and len(words_split) >= 3: + word_second = " ".join(words_split[1:]) + if 'haat' in word_second or 'neen' in word_second: + words = word_first+" "+word_second + else: + words = word_first+" "+word_second+'k' + + if len(str(num)) > 3: + if 'haat' in words_split[-1:] or 'neen' in words_split[-1:]: + words = 'da'+words + else: + words = 'da'+words+'k' + + result = self.title(out + words) + + return result + + def to_ordinal_num(self, value): + self.verify_ordinal(value) + return "%sº" % (value) + + def to_year(self, val, longval=True): + if val < 0: + return self.to_cardinal(abs(val)) + ' antes Kristu' + return self.to_cardinal(val) + + def to_currency(self, val, currency='USD', cents=True): + """ + Args: + val: Numeric value + currency (str): Currency code + cents (bool): Verbose cents + adjective (bool): Prefix currency name with adjective + Returns: + str: Formatted string + + """ + left, right, is_negative = parse_currency_parts(val) + + try: + cr1, cr2 = self.CURRENCY_FORMS[currency] + + except KeyError: + raise NotImplementedError( + 'Currency code "%s" not implemented for "%s"' % + (currency, self.__class__.__name__)) + + minus_str = "%s " % self.negword.strip() if is_negative else "" + money_str = self._money_verbose(left, currency) + cents_str = self._cents_verbose(right, currency) \ + if cents else self._cents_terse(right, currency) + + if right == 0: + return u'%s%s %s' % ( + minus_str, + self.pluralize(left, cr1), + money_str + ) + else: + return u'%s%s %s %s %s' % ( + minus_str, + self.pluralize(left, cr1), + money_str, + self.pluralize(right, cr2), + cents_str + ) diff --git a/tests/test_tet.py b/tests/test_tet.py new file mode 100644 index 00000000..7f005fd5 --- /dev/null +++ b/tests/test_tet.py @@ -0,0 +1,541 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2003, Taro Ogawa. All Rights Reserved. +# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved. + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301 USA + +import decimal +from decimal import Decimal +from unittest import TestCase + +from num2words import num2words +from num2words.lang_TET import Num2Word_TET + + +class Num2WordsTETTest(TestCase): + def setUp(self): + super().setUp() + self.n2w = Num2Word_TET() + + def test_cardinal_integer(self): + self.assertEqual(num2words(1, lang='tet'), 'ida') + self.assertEqual(num2words(2, lang='tet'), 'rua') + self.assertEqual(num2words(3, lang='tet'), 'tolu') + self.assertEqual(num2words(4, lang='tet'), 'haat') + self.assertEqual(num2words(5, lang='tet'), 'lima') + self.assertEqual(num2words(6, lang='tet'), 'neen') + self.assertEqual(num2words(7, lang='tet'), 'hitu') + self.assertEqual(num2words(8, lang='tet'), 'ualu') + self.assertEqual(num2words(9, lang='tet'), 'sia') + self.assertEqual(num2words(10, lang='tet'), 'sanulu') + self.assertEqual(num2words(11, lang='tet'), 'sanulu resin ida') + self.assertEqual(num2words(12, lang='tet'), 'sanulu resin rua') + self.assertEqual(num2words(13, lang='tet'), 'sanulu resin tolu') + self.assertEqual(num2words(14, lang='tet'), 'sanulu resin haat') + self.assertEqual(num2words(15, lang='tet'), 'sanulu resin lima') + self.assertEqual(num2words(16, lang='tet'), 'sanulu resin neen') + self.assertEqual(num2words(17, lang='tet'), 'sanulu resin hitu') + self.assertEqual(num2words(18, lang='tet'), 'sanulu resin ualu') + self.assertEqual(num2words(19, lang='tet'), 'sanulu resin sia') + self.assertEqual(num2words(20, lang='tet'), 'ruanulu') + + self.assertEqual(num2words(21, lang='tet'), 'ruanulu resin ida') + self.assertEqual(num2words(22, lang='tet'), 'ruanulu resin rua') + self.assertEqual(num2words(35, lang='tet'), 'tolunulu resin lima') + self.assertEqual(num2words(99, lang='tet'), 'sianulu resin sia') + + self.assertEqual(num2words(100, lang='tet'), 'atus ida') + self.assertEqual(num2words(101, lang='tet'), 'atus ida ida') + self.assertEqual(num2words(107, lang='tet'), 'atus ida hitu') + self.assertEqual(num2words(110, lang='tet'), 'atus ida sanulu') + self.assertEqual( + num2words(114, lang='tet'), + 'atus ida sanulu resin haat' + ) + self.assertEqual( + num2words(128, lang='tet'), + 'atus ida ruanulu resin ualu' + ) + self.assertEqual( + num2words(151, lang='tet'), + 'atus ida limanulu resin ida' + ) + self.assertEqual( + num2words(713, lang='tet'), + 'atus hitu sanulu resin tolu' + ) + self.assertEqual( + num2words(999, lang='tet'), + 'atus sia sianulu resin sia' + ) + + self.assertEqual(num2words(1000, lang='tet'), 'rihun ida') + self.assertEqual(num2words(1001, lang='tet'), 'rihun ida ida') + self.assertEqual( + num2words(1011, lang='tet'), + 'rihun ida sanulu resin ida' + ) + self.assertEqual( + num2words(1111, lang='tet'), + 'rihun ida atus ida sanulu resin ida' + ) + self.assertEqual( + num2words(2357, lang='tet'), + 'rihun rua atus tolu limanulu resin hitu' + ) + self.assertEqual( + num2words(2200, lang='tet'), + 'rihun rua atus rua' + ) + self.assertEqual( + num2words(2230, lang='tet'), + 'rihun rua atus rua tolunulu' + ) + self.assertEqual( + num2words(73400, lang='tet'), + 'rihun hitunulu resin tolu atus haat' + ) + self.assertEqual( + num2words(73421, lang='tet'), + 'rihun hitunulu resin tolu atus haat ruanulu resin ida' + ) + self.assertEqual(num2words(100000, lang='tet'), 'rihun atus ida') + self.assertEqual( + num2words(250050, lang='tet'), + 'rihun atus rua limanulu limanulu' + ) + self.assertEqual( + num2words(6000000, lang='tet'), 'miliaun neen' + ) + self.assertEqual( + num2words(100000000, lang='tet'), 'miliaun atus ida' + ) + self.assertEqual( + num2words(19000000000, lang='tet'), + 'miliaun rihun sanulu resin sia' + ) + self.assertEqual( + num2words(145000000002, lang='tet'), + 'miliaun rihun atus ida haatnulu resin lima resin rua' + ) + self.assertEqual( + num2words(4635102, lang='tet'), + 'miliaun haat rihun atus neen tolunulu resin lima atus ida rua' + ) + self.assertEqual( + num2words(145254635102, lang='tet'), + "miliaun rihun atus ida haatnulu resin lima atus rua limanulu \ +resin haat rihun atus neen tolunulu resin lima atus ida rua" + ) + self.assertEqual( + num2words(1000000000000, lang='tet'), + 'biliaun ida' + ) + self.assertEqual( + num2words(2000000000000, lang='tet'), + 'biliaun rua' + ) + self.assertEqual( + num2words(1000000000000000, lang='tet'), + 'biliaun rihun ida' + ) + self.assertEqual( + num2words(2000000000000000, lang='tet'), + 'biliaun rihun rua' + ) + self.assertEqual( + num2words(1000000000000000000, lang='tet'), + 'triliaun ida' + ) + self.assertEqual( + num2words(2000000000000000000, lang='tet'), + 'triliaun rua' + ) + + def test_cardinal_integer_negative(self): + self.assertEqual(num2words(-1, lang='tet'), 'menus ida') + self.assertEqual( + num2words(-256, lang='tet'), 'menus atus rua limanulu resin neen' + ) + self.assertEqual(num2words(-1000, lang='tet'), 'menus rihun ida') + self.assertEqual(num2words(-1000000, lang='tet'), 'menus miliaun ida') + self.assertEqual( + num2words(-1234567, lang='tet'), + 'menus miliaun ida rihun atus rua tolunulu resin \ +haat atus lima neenulu resin hitu' + ) + + def test_cardinal_float(self): + self.assertEqual(num2words(Decimal('1.00'), lang='tet'), 'ida') + self.assertEqual(num2words( + Decimal('1.01'), lang='tet'), 'ida vírgula mamuk ida') + self.assertEqual(num2words( + Decimal('1.035'), lang='tet'), 'ida vírgula mamuk tolu lima' + ) + self.assertEqual(num2words( + Decimal('1.35'), lang='tet'), 'ida vírgula tolu lima' + ) + self.assertEqual( + num2words(Decimal('3.14159'), lang='tet'), + 'tolu vírgula ida haat ida lima sia' + ) + self.assertEqual( + num2words(Decimal('101.22'), lang='tet'), + 'atus ida ida vírgula rua rua' + ) + self.assertEqual( + num2words(Decimal('2345.75'), lang='tet'), + 'rihun rua atus tolu haatnulu resin lima vírgula hitu lima' + ) + + def test_cardinal_float_negative(self): + self.assertEqual( + num2words(Decimal('-2.34'), lang='tet'), + 'menus rua vírgula tolu haat' + ) + self.assertEqual( + num2words(Decimal('-9.99'), lang='tet'), + 'menus sia vírgula sia sia' + ) + self.assertEqual( + num2words(Decimal('-7.01'), lang='tet'), + 'menus hitu vírgula mamuk ida' + ) + self.assertEqual( + num2words(Decimal('-222.22'), lang='tet'), + 'menus atus rua ruanulu resin rua vírgula rua rua' + ) + + def test_ordinal(self): + with self.assertRaises(decimal.InvalidOperation): + num2words("hello", lang='tet', ordinal=True) + with self.assertRaises(TypeError): + num2words(5.1, lang='tet', ordinal=True) + self.assertEqual(num2words(1, lang='tet', ordinal=True), 'dahuluk') + self.assertEqual(num2words(2, lang='tet', ordinal=True), 'daruak') + self.assertEqual(num2words(3, lang='tet', ordinal=True), 'datoluk') + self.assertEqual(num2words(4, lang='tet', ordinal=True), 'dahaat') + self.assertEqual(num2words(5, lang='tet', ordinal=True), 'dalimak') + self.assertEqual(num2words(6, lang='tet', ordinal=True), 'daneen') + self.assertEqual(num2words(7, lang='tet', ordinal=True), 'dahituk') + self.assertEqual(num2words(8, lang='tet', ordinal=True), 'daualuk') + self.assertEqual(num2words(9, lang='tet', ordinal=True), 'dasiak') + self.assertEqual(num2words(10, lang='tet', ordinal=True), 'dasanuluk') + self.assertEqual( + num2words(11, lang='tet', ordinal=True), 'dasanulu resin idak' + ) + self.assertEqual( + num2words(12, lang='tet', ordinal=True), 'dasanulu resin ruak' + ) + self.assertEqual( + num2words(13, lang='tet', ordinal=True), 'dasanulu resin toluk' + ) + self.assertEqual( + num2words(14, lang='tet', ordinal=True), 'dasanulu resin haat' + ) + self.assertEqual( + num2words(15, lang='tet', ordinal=True), 'dasanulu resin limak' + ) + self.assertEqual( + num2words(16, lang='tet', ordinal=True), 'dasanulu resin neen' + ) + self.assertEqual( + num2words(17, lang='tet', ordinal=True), 'dasanulu resin hituk' + ) + self.assertEqual( + num2words(18, lang='tet', ordinal=True), 'dasanulu resin ualuk' + ) + self.assertEqual( + num2words(19, lang='tet', ordinal=True), 'dasanulu resin siak' + ) + self.assertEqual( + num2words(20, lang='tet', ordinal=True), 'daruanuluk' + ) + + self.assertEqual( + num2words(21, lang='tet', ordinal=True), 'daruanulu resin idak' + ) + self.assertEqual( + num2words(22, lang='tet', ordinal=True), 'daruanulu resin ruak' + ) + self.assertEqual( + num2words(35, lang='tet', ordinal=True), 'datolunulu resin limak' + ) + self.assertEqual( + num2words(99, lang='tet', ordinal=True), 'dasianulu resin siak' + ) + + self.assertEqual( + num2words(100, lang='tet', ordinal=True), 'dahatus idak' + ) + self.assertEqual( + num2words(101, lang='tet', ordinal=True), 'dahatus ida idak' + ) + self.assertEqual( + num2words(106, lang='tet', ordinal=True), 'dahatus ida neen' + ) + self.assertEqual( + num2words(128, lang='tet', ordinal=True), + 'dahatus ida ruanulu resin ualuk' + ) + self.assertEqual( + num2words(600, lang='tet', ordinal=True), + 'dahatus neen' + ) + self.assertEqual( + num2words(713, lang='tet', ordinal=True), + 'dahatus hitu sanulu resin toluk' + ) + + self.assertEqual( + num2words(1000, lang='tet', ordinal=True), 'darihun idak' + ) + self.assertEqual( + num2words(1001, lang='tet', ordinal=True), 'darihun ida idak' + ) + self.assertEqual( + num2words(1111, lang='tet', ordinal=True), + 'darihun ida atus ida sanulu resin idak' + ) + self.assertEqual( + num2words(2114, lang='tet', ordinal=True), + 'darihun rua atus ida sanulu resin haat' + ) + self.assertEqual( + num2words(73421, lang='tet', ordinal=True), + 'darihun hitunulu resin tolu atus haat ruanulu resin idak' + ) + + self.assertEqual( + num2words(100000, lang='tet', ordinal=True), + 'darihun atus idak' + ) + self.assertEqual( + num2words(250050, lang='tet', ordinal=True), + 'darihun atus rua limanulu limanuluk' + ) + self.assertEqual( + num2words(6000000, lang='tet', ordinal=True), 'damiliaun neen' + ) + self.assertEqual( + num2words(19000000000, lang='tet', ordinal=True), + 'damiliaun rihun sanulu resin siak' + ) + self.assertEqual( + num2words(145000000002, lang='tet', ordinal=True), + 'damiliaun rihun atus ida haatnulu resin lima resin ruak' + ) + + def test_currency_integer(self): + self.assertEqual(self.n2w.to_currency(1.00), 'dolar ida') + self.assertEqual(self.n2w.to_currency(2.00), 'dolar rua') + self.assertEqual(self.n2w.to_currency(3.00), 'dolar tolu') + self.assertEqual(self.n2w.to_currency(4.00), 'dolar haat') + self.assertEqual(self.n2w.to_currency(5.00), 'dolar lima') + self.assertEqual(self.n2w.to_currency(6.00), 'dolar neen') + self.assertEqual(self.n2w.to_currency(7.00), 'dolar hitu') + self.assertEqual(self.n2w.to_currency(8.00), 'dolar ualu') + self.assertEqual(self.n2w.to_currency(9.00), 'dolar sia') + self.assertEqual(self.n2w.to_currency(10.00), 'dolar sanulu') + self.assertEqual(self.n2w.to_currency(11.00), 'dolar sanulu resin ida') + self.assertEqual(self.n2w.to_currency(12.00), 'dolar sanulu resin rua') + self.assertEqual( + self.n2w.to_currency(13.00), + 'dolar sanulu resin tolu' + ) + self.assertEqual( + self.n2w.to_currency(14.00), + 'dolar sanulu resin haat' + ) + self.assertEqual( + self.n2w.to_currency(15.00), + 'dolar sanulu resin lima' + ) + self.assertEqual( + self.n2w.to_currency(16.00), + 'dolar sanulu resin neen' + ) + self.assertEqual( + self.n2w.to_currency(17.00), + 'dolar sanulu resin hitu' + ) + self.assertEqual( + self.n2w.to_currency(18.00), + 'dolar sanulu resin ualu' + ) + self.assertEqual( + self.n2w.to_currency(19.00), + 'dolar sanulu resin sia' + ) + self.assertEqual(self.n2w.to_currency(20.00), 'dolar ruanulu') + + self.assertEqual( + self.n2w.to_currency(21.00), + 'dolar ruanulu resin ida' + ) + self.assertEqual( + self.n2w.to_currency(22.00), + 'dolar ruanulu resin rua' + ) + self.assertEqual( + self.n2w.to_currency(35.00), + 'dolar tolunulu resin lima' + ) + self.assertEqual( + self.n2w.to_currency(99.00), + 'dolar sianulu resin sia' + ) + + self.assertEqual(self.n2w.to_currency(100.00), 'dolar atus ida') + self.assertEqual(self.n2w.to_currency(101.00), 'dolar atus ida ida') + self.assertEqual( + self.n2w.to_currency(128.00), 'dolar atus ida ruanulu resin ualu' + ) + self.assertEqual( + self.n2w.to_currency(713.00), 'dolar atus hitu sanulu resin tolu') + + self.assertEqual(self.n2w.to_currency(1000.00), 'dolar rihun ida') + self.assertEqual(self.n2w.to_currency(1001.00), 'dolar rihun ida ida') + self.assertEqual( + self.n2w.to_currency(1111.00), + 'dolar rihun ida atus ida sanulu resin ida' + ) + self.assertEqual( + self.n2w.to_currency(2114.00), + 'dolar rihun rua atus ida sanulu resin haat' + ) + self.assertEqual( + self.n2w.to_currency(73421.00), + 'dolar rihun hitunulu resin tolu atus haat ruanulu resin ida' + ) + + self.assertEqual( + self.n2w.to_currency(100000.00), + 'dolar rihun atus ida' + ) + self.assertEqual( + self.n2w.to_currency(250050.00), + 'dolar rihun atus rua limanulu limanulu' + ) + self.assertEqual( + self.n2w.to_currency(6000000.00), + 'dolar miliaun neen' + ) + self.assertEqual( + self.n2w.to_currency(19000000000.00), + 'dolar miliaun rihun sanulu resin sia' + ) + self.assertEqual( + self.n2w.to_currency(145000000002.00), + 'dolar miliaun rihun atus ida haatnulu resin lima resin rua' + ) + self.assertEqual(self.n2w.to_currency(1.00, currency='USD'), + 'dolar ida') + self.assertEqual(self.n2w.to_currency(1.50, currency='USD'), + 'dolar ida sentavu limanulu') + with self.assertRaises(NotImplementedError): + self.n2w.to_currency(1.00, currency='CHF') + + def test_currency_integer_negative(self): + self.assertEqual(self.n2w.to_currency(-1.00), 'menus dolar ida') + self.assertEqual( + self.n2w.to_currency(-256.00), + 'menus dolar atus rua limanulu resin neen' + ) + self.assertEqual( + self.n2w.to_currency(-1000.00), + 'menus dolar rihun ida' + ) + self.assertEqual( + self.n2w.to_currency(-1000000.00), 'menus dolar miliaun ida' + ) + self.assertEqual( + self.n2w.to_currency(-1234567.00), + 'menus dolar miliaun ida rihun atus rua tolunulu \ +resin haat atus lima neenulu resin hitu' + ) + + def test_currency_float(self): + self.assertEqual(self.n2w.to_currency(Decimal('1.00')), 'dolar ida') + self.assertEqual( + self.n2w.to_currency(Decimal('1.01')), 'dolar ida sentavu ida' + ) + self.assertEqual( + self.n2w.to_currency(Decimal('1.03')), 'dolar ida sentavu tolu' + ) + self.assertEqual( + self.n2w.to_currency(Decimal('1.35')), + 'dolar ida sentavu tolunulu resin lima' + ) + self.assertEqual( + self.n2w.to_currency(Decimal('3.14')), + 'dolar tolu sentavu sanulu resin haat' + ) + self.assertEqual( + self.n2w.to_currency(Decimal('101.22')), + 'dolar atus ida ida sentavu ruanulu resin rua' + ) + self.assertEqual( + self.n2w.to_currency(Decimal('2345.75')), + 'dolar rihun rua atus tolu haatnulu resin \ +lima sentavu hitunulu resin lima' + ) + + def test_currency_float_negative(self): + self.assertEqual( + self.n2w.to_currency(Decimal('-2.34')), + 'menus dolar rua sentavu tolunulu resin haat' + ) + self.assertEqual( + self.n2w.to_currency(Decimal('-9.99')), + 'menus dolar sia sentavu sianulu resin sia' + ) + self.assertEqual( + self.n2w.to_currency(Decimal('-7.01')), + 'menus dolar hitu sentavu ida' + ) + self.assertEqual( + self.n2w.to_currency(Decimal('-222.22')), + 'menus dolar atus rua ruanulu resin rua sentavu ruanulu resin rua' + ) + + def test_year(self): + self.assertEqual(self.n2w.to_year(1001), 'rihun ida ida') + self.assertEqual( + self.n2w.to_year(1789), 'rihun ida atus hitu ualunulu resin sia' + ) + self.assertEqual( + self.n2w.to_year(1942), 'rihun ida atus sia haatnulu resin rua' + ) + self.assertEqual( + self.n2w.to_year(1984), 'rihun ida atus sia ualunulu resin haat' + ) + self.assertEqual(self.n2w.to_year(2000), 'rihun rua') + self.assertEqual(self.n2w.to_year(2001), 'rihun rua ida') + self.assertEqual(self.n2w.to_year(2016), 'rihun rua sanulu resin neen') + + def test_year_negative(self): + self.assertEqual(self.n2w.to_year(-30), 'tolunulu antes Kristu') + self.assertEqual( + self.n2w.to_year(-744), + 'atus hitu haatnulu resin haat antes Kristu' + ) + self.assertEqual( + self.n2w.to_year(-10000), + 'rihun sanulu antes Kristu' + ) + + def test_to_ordinal_num(self): + self.assertEqual(self.n2w.to_ordinal_num(1), '1º') + self.assertEqual(self.n2w.to_ordinal_num(100), '100º')