mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
Long form for currency name is optional. Currency name rendering in e… (#133)
* Long form for currency name is optional. Currency name rendering in english. * Missing encoding header.
This commit is contained in:
committed by
Ernesto Rodriguez Ortiz
parent
ee9f767b06
commit
5a131fedc6
@@ -29,3 +29,33 @@ class Num2WordsENTest(TestCase):
|
||||
self.assertEqual(num2words(12.51), "twelve point five one")
|
||||
self.assertEqual(num2words(12.53), "twelve point five three")
|
||||
self.assertEqual(num2words(12.59), "twelve point five nine")
|
||||
|
||||
def test_to_currency(self):
|
||||
self.assertEqual(
|
||||
num2words('38.4', lang='en', to='currency', seperator=' and',
|
||||
cents=False, currency='USD'),
|
||||
"thirty-eight dollars and 40 cents"
|
||||
)
|
||||
self.assertEqual(
|
||||
num2words('0', lang='en', to='currency', seperator=' and',
|
||||
cents=False, currency='USD'),
|
||||
"zero dollars and 00 cents"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
num2words('1.01', lang='en', to='currency', seperator=' and',
|
||||
cents=True, currency='USD'),
|
||||
"one dollar and one cent"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
num2words('4778.00', lang='en', to='currency', seperator=' and',
|
||||
cents=True, currency='USD', prefix=True),
|
||||
'four thousand, seven hundred and seventy-eight US dollars'
|
||||
' and zero cents')
|
||||
|
||||
self.assertEqual(
|
||||
num2words('4778.00', lang='en', to='currency', seperator=' and',
|
||||
cents=True, currency='USD'),
|
||||
'four thousand, seven hundred and seventy-eight dollars and'
|
||||
' zero cents')
|
||||
|
||||
@@ -41,7 +41,13 @@ class Num2WordsLVTest(TestCase):
|
||||
|
||||
self.assertEqual(
|
||||
num2words('38.4', lang='lv', to='currency', seperator=' un',
|
||||
cents=False, currency='USD'),
|
||||
cents=False, currency='USD', prefix=False),
|
||||
"trīsdesmit astoņi dolāri un 40 centi"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
num2words('38.4', lang='lv', to='currency', seperator=' un',
|
||||
cents=False, currency='USD', prefix=True),
|
||||
"trīsdesmit astoņi ASV dolāri un 40 centi"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user