|
148 | 148 | (100.00, 'cent dollars et zéro cents'),
|
149 | 149 | )
|
150 | 150 |
|
| 151 | +TEST_CASES_TO_CURRENCY_CAD = ( |
| 152 | + (1.00, 'un dollar et zéro cents'), |
| 153 | + (2.01, 'deux dollars et un cent'), |
| 154 | + (8.10, 'huit dollars et dix cents'), |
| 155 | + (12.26, 'douze dollars et vingt-six cents'), |
| 156 | + (21.29, 'vingt et un dollars et vingt-neuf cents'), |
| 157 | + (81.25, 'quatre-vingt-un dollars et vingt-cinq cents'), |
| 158 | + (100.00, 'cent dollars et zéro cents'), |
| 159 | +) |
| 160 | + |
| 161 | +TEST_CASES_TO_CURRENCY_AUD = ( |
| 162 | + (1.00, 'un dollar et zéro cents'), |
| 163 | + (2.01, 'deux dollars et un cent'), |
| 164 | + (8.10, 'huit dollars et dix cents'), |
| 165 | + (12.26, 'douze dollars et vingt-six cents'), |
| 166 | + (21.29, 'vingt et un dollars et vingt-neuf cents'), |
| 167 | + (81.25, 'quatre-vingt-un dollars et vingt-cinq cents'), |
| 168 | + (100.00, 'cent dollars et zéro cents'), |
| 169 | +) |
| 170 | + |
| 171 | +TEST_CASES_TO_CURRENCY_NZD = ( |
| 172 | + (1.00, 'un dollar et zéro cents'), |
| 173 | + (2.01, 'deux dollars et un cent'), |
| 174 | + (8.10, 'huit dollars et dix cents'), |
| 175 | + (12.26, 'douze dollars et vingt-six cents'), |
| 176 | + (21.29, 'vingt et un dollars et vingt-neuf cents'), |
| 177 | + (81.25, 'quatre-vingt-un dollars et vingt-cinq cents'), |
| 178 | + (100.00, 'cent dollars et zéro cents'), |
| 179 | +) |
| 180 | + |
| 181 | +TEST_CASES_TO_CURRENCY_HKD = ( |
| 182 | + (1.00, 'un dollar et zéro cents'), |
| 183 | + (2.01, 'deux dollars et un cent'), |
| 184 | + (8.10, 'huit dollars et dix cents'), |
| 185 | + (12.26, 'douze dollars et vingt-six cents'), |
| 186 | + (21.29, 'vingt et un dollars et vingt-neuf cents'), |
| 187 | + (81.25, 'quatre-vingt-un dollars et vingt-cinq cents'), |
| 188 | + (100.00, 'cent dollars et zéro cents'), |
| 189 | +) |
| 190 | + |
| 191 | +TEST_CASES_TO_CURRENCY_GBP = ( |
| 192 | + (1.00, 'un livre et zéro pence'), |
| 193 | + (2.01, 'deux livres et un penny'), |
| 194 | + (8.10, 'huit livres et dix pence'), |
| 195 | + (12.26, 'douze livres et vingt-six pence'), |
| 196 | + (21.29, 'vingt et un livres et vingt-neuf pence'), |
| 197 | + (81.25, 'quatre-vingt-un livres et vingt-cinq pence'), |
| 198 | + (100.00, 'cent livres et zéro pence'), |
| 199 | +) |
| 200 | + |
| 201 | +TEST_CASES_TO_CURRENCY_CNY = ( |
| 202 | + (1.00, 'un yuan et zéro jiaos'), |
| 203 | + (2.01, 'deux yuans et un fen'), |
| 204 | + (8.10, 'huit yuans et dix jiaos'), |
| 205 | + (12.26, 'douze yuans et vingt-six jiaos'), |
| 206 | + (21.29, 'vingt et un yuans et vingt-neuf jiaos'), |
| 207 | + (81.25, 'quatre-vingt-un yuans et vingt-cinq jiaos'), |
| 208 | + (100.00, 'cent yuans et zéro jiaos'), |
| 209 | +) |
| 210 | + |
| 211 | +TEST_CASES_TO_CURRENCY_JPY = ( |
| 212 | + (1.00, 'un yen et zéro sen'), |
| 213 | + (2.01, 'deux yens et un sen'), |
| 214 | + (8.10, 'huit yens et dix sen'), |
| 215 | + (12.26, 'douze yens et vingt-six sen'), |
| 216 | + (21.29, 'vingt et un yens et vingt-neuf sen'), |
| 217 | + (81.25, 'quatre-vingt-un yens et vingt-cinq sen'), |
| 218 | + (100.00, 'cent yens et zéro sen'), |
| 219 | +) |
| 220 | + |
| 221 | +TEST_CASES_TO_CURRENCY_INR = ( |
| 222 | + (1.00, 'un roupie et zéro paisas'), |
| 223 | + (2.01, 'deux roupies et un paisa'), |
| 224 | + (8.10, 'huit roupies et dix paisas'), |
| 225 | + (12.26, 'douze roupies et vingt-six paisas'), |
| 226 | + (21.29, 'vingt et un roupies et vingt-neuf paisas'), |
| 227 | + (81.25, 'quatre-vingt-un roupies et vingt-cinq paisas'), |
| 228 | + (100.00, 'cent roupies et zéro paisas'), |
| 229 | +) |
| 230 | + |
| 231 | +TEST_CASES_TO_CURRENCY_RUB = ( |
| 232 | + (1.00, 'un rouble et zéro kopecks'), |
| 233 | + (2.01, 'deux roubles et un kopeck'), |
| 234 | + (8.10, 'huit roubles et dix kopecks'), |
| 235 | + (12.26, 'douze roubles et vingt-six kopecks'), |
| 236 | + (21.29, 'vingt et un roubles et vingt-neuf kopecks'), |
| 237 | + (81.25, 'quatre-vingt-un roubles et vingt-cinq kopecks'), |
| 238 | + (100.00, 'cent roubles et zéro kopecks'), |
| 239 | +) |
| 240 | + |
| 241 | +TEST_CASES_TO_CURRENCY_KRW = ( |
| 242 | + (1.00, 'un won et zéro jeons'), |
| 243 | + (2.01, 'deux wons et un jeon'), |
| 244 | + (8.10, 'huit wons et dix jeons'), |
| 245 | + (12.26, 'douze wons et vingt-six jeons'), |
| 246 | + (21.29, 'vingt et un wons et vingt-neuf jeons'), |
| 247 | + (81.25, 'quatre-vingt-un wons et vingt-cinq jeons'), |
| 248 | + (100.00, 'cent wons et zéro jeons'), |
| 249 | +) |
| 250 | + |
| 251 | +TEST_CASES_TO_CURRENCY_MXN = ( |
| 252 | + (1.00, 'un peso et zéro centavos'), |
| 253 | + (2.01, 'deux pesos et un centavo'), |
| 254 | + (8.10, 'huit pesos et dix centavos'), |
| 255 | + (12.26, 'douze pesos et vingt-six centavos'), |
| 256 | + (21.29, 'vingt et un pesos et vingt-neuf centavos'), |
| 257 | + (81.25, 'quatre-vingt-un pesos et vingt-cinq centavos'), |
| 258 | + (100.00, 'cent pesos et zéro centavos'), |
| 259 | +) |
| 260 | + |
151 | 261 |
|
152 | 262 | class Num2WordsFRTest(TestCase):
|
153 | 263 | def test_ordinal_special_joins(self):
|
@@ -204,6 +314,83 @@ def test_currency_usd(self):
|
204 | 314 | test[1]
|
205 | 315 | )
|
206 | 316 |
|
| 317 | + def test_currency_cad(self): |
| 318 | + for test in TEST_CASES_TO_CURRENCY_CAD: |
| 319 | + self.assertEqual( |
| 320 | + num2words(test[0], lang='fr', to='currency', currency='CAD'), |
| 321 | + test[1] |
| 322 | + ) |
| 323 | + |
| 324 | + def test_currency_aud(self): |
| 325 | + for test in TEST_CASES_TO_CURRENCY_AUD: |
| 326 | + self.assertEqual( |
| 327 | + num2words(test[0], lang='fr', to='currency', currency='AUD'), |
| 328 | + test[1] |
| 329 | + ) |
| 330 | + |
| 331 | + def test_currency_nzd(self): |
| 332 | + for test in TEST_CASES_TO_CURRENCY_NZD: |
| 333 | + self.assertEqual( |
| 334 | + num2words(test[0], lang='fr', to='currency', currency='NZD'), |
| 335 | + test[1] |
| 336 | + ) |
| 337 | + |
| 338 | + def test_currency_hkd(self): |
| 339 | + for test in TEST_CASES_TO_CURRENCY_HKD: |
| 340 | + self.assertEqual( |
| 341 | + num2words(test[0], lang='fr', to='currency', currency='HKD'), |
| 342 | + test[1] |
| 343 | + ) |
| 344 | + |
| 345 | + def test_currency_gbp(self): |
| 346 | + for test in TEST_CASES_TO_CURRENCY_GBP: |
| 347 | + self.assertEqual( |
| 348 | + num2words(test[0], lang='fr', to='currency', currency='GBP'), |
| 349 | + test[1] |
| 350 | + ) |
| 351 | + |
| 352 | + def test_currency_cny(self): |
| 353 | + for test in TEST_CASES_TO_CURRENCY_CNY: |
| 354 | + self.assertEqual( |
| 355 | + num2words(test[0], lang='fr', to='currency', currency='CNY'), |
| 356 | + test[1] |
| 357 | + ) |
| 358 | + |
| 359 | + def test_currency_jpy(self): |
| 360 | + for test in TEST_CASES_TO_CURRENCY_JPY: |
| 361 | + self.assertEqual( |
| 362 | + num2words(test[0], lang='fr', to='currency', currency='JPY'), |
| 363 | + test[1] |
| 364 | + ) |
| 365 | + |
| 366 | + def test_currency_inr(self): |
| 367 | + for test in TEST_CASES_TO_CURRENCY_INR: |
| 368 | + self.assertEqual( |
| 369 | + num2words(test[0], lang='fr', to='currency', currency='INR'), |
| 370 | + test[1] |
| 371 | + ) |
| 372 | + |
| 373 | + def test_currency_rub(self): |
| 374 | + for test in TEST_CASES_TO_CURRENCY_RUB: |
| 375 | + self.assertEqual( |
| 376 | + num2words(test[0], lang='fr', to='currency', currency='RUB'), |
| 377 | + test[1] |
| 378 | + ) |
| 379 | + |
| 380 | + def test_currency_krw(self): |
| 381 | + for test in TEST_CASES_TO_CURRENCY_KRW: |
| 382 | + self.assertEqual( |
| 383 | + num2words(test[0], lang='fr', to='currency', currency='KRW'), |
| 384 | + test[1] |
| 385 | + ) |
| 386 | + |
| 387 | + def test_currency_mxn(self): |
| 388 | + for test in TEST_CASES_TO_CURRENCY_MXN: |
| 389 | + self.assertEqual( |
| 390 | + num2words(test[0], lang='fr', to='currency', currency='MXN'), |
| 391 | + test[1] |
| 392 | + ) |
| 393 | + |
207 | 394 | def test_max_numbers(self):
|
208 | 395 |
|
209 | 396 | with self.assertRaises(OverflowError) as context:
|
|
0 commit comments