2
2
3
3
from say import say
4
4
5
-
6
5
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0
7
6
7
+
8
8
class SayTest (unittest .TestCase ):
9
9
def test_zero (self ):
10
10
self .assertEqual (say (0 ), "zero" )
@@ -24,46 +24,44 @@ def test_twenty_two(self):
24
24
def test_one_hundred (self ):
25
25
self .assertEqual (say (100 ), "one hundred" )
26
26
27
- # additional track specific test
28
27
def test_one_hundred_twenty_three (self ):
29
- self .assertEqual (say (123 ), "one hundred and twenty-three" )
28
+ self .assertEqual (say (123 ), "one hundred twenty-three" )
30
29
31
30
def test_one_thousand (self ):
32
31
self .assertEqual (say (1000 ), "one thousand" )
33
32
34
33
def test_one_thousand_two_hundred_thirty_four (self ):
35
- self .assertEqual (say (1234 ), "one thousand two hundred and thirty-four" )
34
+ self .assertEqual (say (1234 ), "one thousand two hundred thirty-four" )
36
35
37
36
def test_one_million (self ):
38
37
self .assertEqual (say (1000000 ), "one million" )
39
38
40
- def test_1002345 (self ):
39
+ def test_one_million_two_thousand_three_hundred_forty_five (self ):
41
40
self .assertEqual (
42
- say (1002345 ),
43
- "one million two thousand three hundred and forty-five" )
41
+ say (1002345 ), "one million two thousand three hundred forty-five"
42
+ )
44
43
45
44
def test_one_billion (self ):
46
45
self .assertEqual (say (1000000000 ), "one billion" )
47
46
48
- def test_987654321123 (self ):
47
+ def test_a_big_number (self ):
49
48
self .assertEqual (
50
- say (987654321123 ), ("nine hundred and eighty-seven billion "
51
- "six hundred and fifty-four million "
52
- "three hundred and twenty-one thousand "
53
- "one hundred and twenty-three" ))
49
+ say (987654321123 ),
50
+ "nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three" ,
51
+ )
54
52
55
- def test_number_too_large (self ):
53
+ def test_numbers_below_zero_are_out_of_range (self ):
56
54
with self .assertRaisesWithMessage (ValueError ):
57
- say (1000000000000 )
55
+ say (- 1 )
58
56
59
- def test_number_negative (self ):
57
+ def test_numbers_above_999_999_999_999_are_out_of_range (self ):
60
58
with self .assertRaisesWithMessage (ValueError ):
61
- say (- 1 )
59
+ say (1000000000000 )
62
60
63
61
# Utility functions
64
62
def assertRaisesWithMessage (self , exception ):
65
63
return self .assertRaisesRegex (exception , r".+" )
66
64
67
65
68
- if __name__ == ' __main__' :
66
+ if __name__ == " __main__" :
69
67
unittest .main ()
0 commit comments