Skip to content

Commit 389bfd5

Browse files
committed
Add tests for italian language currencies
1 parent e842502 commit 389bfd5

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

tests/test_it.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,36 @@
2121

2222
from num2words import num2words
2323

24+
TEST_CASES_TO_CURRENCY_EUR = (
25+
(1.00, 'un euro e zero centesimi'),
26+
(2.01, 'due euro e un centesimo'),
27+
(8.10, 'otto euro e dieci centesimi'),
28+
(12.26, 'dodici euro e ventisei centesimi'),
29+
(21.29, 'ventun euro e ventinove centesimi'),
30+
(81.25, 'ottantun euro e venticinque centesimi'),
31+
(100.00, 'cento euro e zero centesimi'),
32+
)
33+
34+
TEST_CASES_TO_CURRENCY_USD = (
35+
(1.00, 'un dollaro e zero centesimi'),
36+
(2.01, 'due dollari e un centesimo'),
37+
(8.10, 'otto dollari e dieci centesimi'),
38+
(12.26, 'dodici dollari e ventisei centesimi'),
39+
(21.29, 'ventun dollari e ventinove centesimi'),
40+
(81.25, 'ottantun dollari e venticinque centesimi'),
41+
(100.00, 'cento dollari e zero centesimi'),
42+
)
43+
44+
TEST_CASES_TO_CURRENCY_GBP = (
45+
(1.00, 'una sterlina e zero penny'),
46+
(2.01, 'due sterline e un penny'),
47+
(8.10, 'otto sterline e dieci penny'),
48+
(12.26, 'dodici sterline e ventisei penny'),
49+
(21.29, 'ventun sterline e ventinove penny'),
50+
(81.25, 'ottantun sterline e venticinque penny'),
51+
(100.00, 'cento sterline e zero penny'),
52+
)
53+
2454

2555
class Num2WordsITTest(TestCase):
2656
maxDiff = None
@@ -240,3 +270,24 @@ def test_with_decimals(self):
240270
self.assertAlmostEqual(
241271
num2words(1.1, lang="it"), "uno virgola uno"
242272
)
273+
274+
def test_currency_eur(self):
275+
for test in TEST_CASES_TO_CURRENCY_EUR:
276+
self.assertEqual(
277+
num2words(test[0], lang='it', to='currency', currency='EUR'),
278+
test[1]
279+
)
280+
281+
def test_currency_usd(self):
282+
for test in TEST_CASES_TO_CURRENCY_USD:
283+
self.assertEqual(
284+
num2words(test[0], lang='it', to='currency', currency='USD'),
285+
test[1]
286+
)
287+
288+
def test_currency_gbp(self):
289+
for test in TEST_CASES_TO_CURRENCY_GBP:
290+
self.assertEqual(
291+
num2words(test[0], lang='it', to='currency', currency='GBP'),
292+
test[1]
293+
)

0 commit comments

Comments
 (0)