# test_numberwords.py # ------------------- # By MWC Contributors # Run this file to test your implementation of numberwords.py import unittest from numberwords import ( int_under_10_to_str, int_under_20_to_str, int_under_100_to_str, int_under_1000_to_str, int_under_1000000_to_str, ) class TestIntToStr(unittest.TestCase): cases = [ [int_under_10_to_str, 0, 'zero'], [int_under_10_to_str, 3, 'three'], [int_under_10_to_str, 9, 'nine'], [int_under_20_to_str, 9, 'nine'], [int_under_20_to_str, 10, 'ten'], [int_under_20_to_str, 11, 'eleven'], [int_under_20_to_str, 18, 'eighteen'], [int_under_100_to_str, 18, 'eighteen'], [int_under_100_to_str, 43, 'forty-three'], [int_under_100_to_str, 60, 'sixty'], [int_under_100_to_str, 89, 'eighty-nine'], [int_under_1000_to_str, 89, 'eighty-nine'], [int_under_1000_to_str, 100, 'one hundred'], [int_under_1000_to_str, 212, 'two hundred and twelve'], [int_under_1000_to_str, 755, 'seven hundred and fifty-five'], [int_under_1000000_to_str, 1000, 'one thousand'], [int_under_1000000_to_str, 1001, 'one thousand one'], [int_under_1000000_to_str, 1672, 'one thousand six hundred and seventy-two'], [int_under_1000000_to_str, 10000, 'ten thousand'], [int_under_1000000_to_str, 588567, 'five hundred and ninety-eight thousand five hundred and sixty-seven'], ] def test_converts_integer_to_string(self): for function, argument, expected in self.cases: observed = function(argument) with self.subTest(msg=function.__name__): self.assertEqual(observed, expected) unittest.main()