Skip to content

Commit 77adc53

Browse files
committed
Add tests for italian language currencies
1 parent 2604d64 commit 77adc53

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/test_it.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,35 @@
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, 'ventuno euro e ventinove centesimi'),
30+
(81.25, 'ottantuno 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, 'ventuno dollari e ventinove centesimi'),
40+
(81.25, 'ottantuno 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, 'ventuno sterline e ventinove penny'),
50+
(81.25, 'ottantuno sterline e venticinque penny'),
51+
(100.00, 'cento sterline e zero penny'),
52+
)
2453

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

0 commit comments

Comments
 (0)