|
1 | | -use wordy::answer; |
2 | | - |
3 | 1 | #[test] |
4 | 2 | fn just_a_number() { |
5 | | - let command = "What is 5?"; |
6 | | - assert_eq!(Some(5), answer(command)); |
| 3 | + let input = "What is 5?"; |
| 4 | + let output = wordy::answer(input); |
| 5 | + let expected = Some(5); |
| 6 | + assert_eq!(output, expected); |
7 | 7 | } |
8 | 8 |
|
9 | 9 | #[test] |
10 | 10 | #[ignore] |
11 | 11 | fn addition() { |
12 | | - let command = "What is 1 plus 1?"; |
13 | | - assert_eq!(Some(2), answer(command)); |
| 12 | + let input = "What is 1 plus 1?"; |
| 13 | + let output = wordy::answer(input); |
| 14 | + let expected = Some(2); |
| 15 | + assert_eq!(output, expected); |
14 | 16 | } |
15 | 17 |
|
16 | 18 | #[test] |
17 | 19 | #[ignore] |
18 | 20 | fn more_addition() { |
19 | | - let command = "What is 53 plus 2?"; |
20 | | - assert_eq!(Some(55), answer(command)); |
| 21 | + let input = "What is 53 plus 2?"; |
| 22 | + let output = wordy::answer(input); |
| 23 | + let expected = Some(55); |
| 24 | + assert_eq!(output, expected); |
21 | 25 | } |
22 | 26 |
|
23 | 27 | #[test] |
24 | 28 | #[ignore] |
25 | 29 | fn addition_with_negative_numbers() { |
26 | | - let command = "What is -1 plus -10?"; |
27 | | - assert_eq!(Some(-11), answer(command)); |
| 30 | + let input = "What is -1 plus -10?"; |
| 31 | + let output = wordy::answer(input); |
| 32 | + let expected = Some(-11); |
| 33 | + assert_eq!(output, expected); |
28 | 34 | } |
29 | 35 |
|
30 | 36 | #[test] |
31 | 37 | #[ignore] |
32 | 38 | fn large_addition() { |
33 | | - let command = "What is 123 plus 45678?"; |
34 | | - assert_eq!(Some(45_801), answer(command)); |
| 39 | + let input = "What is 123 plus 45678?"; |
| 40 | + let output = wordy::answer(input); |
| 41 | + let expected = Some(45801); |
| 42 | + assert_eq!(output, expected); |
35 | 43 | } |
36 | 44 |
|
37 | 45 | #[test] |
38 | 46 | #[ignore] |
39 | 47 | fn subtraction() { |
40 | | - let command = "What is 4 minus -12?"; |
41 | | - assert_eq!(Some(16), answer(command)); |
| 48 | + let input = "What is 4 minus -12?"; |
| 49 | + let output = wordy::answer(input); |
| 50 | + let expected = Some(16); |
| 51 | + assert_eq!(output, expected); |
42 | 52 | } |
43 | 53 |
|
44 | 54 | #[test] |
45 | 55 | #[ignore] |
46 | 56 | fn multiplication() { |
47 | | - let command = "What is -3 multiplied by 25?"; |
48 | | - assert_eq!(Some(-75), answer(command)); |
| 57 | + let input = "What is -3 multiplied by 25?"; |
| 58 | + let output = wordy::answer(input); |
| 59 | + let expected = Some(-75); |
| 60 | + assert_eq!(output, expected); |
49 | 61 | } |
50 | 62 |
|
51 | 63 | #[test] |
52 | 64 | #[ignore] |
53 | 65 | fn division() { |
54 | | - let command = "What is 33 divided by -3?"; |
55 | | - assert_eq!(Some(-11), answer(command)); |
| 66 | + let input = "What is 33 divided by -3?"; |
| 67 | + let output = wordy::answer(input); |
| 68 | + let expected = Some(-11); |
| 69 | + assert_eq!(output, expected); |
56 | 70 | } |
57 | 71 |
|
58 | 72 | #[test] |
59 | 73 | #[ignore] |
60 | 74 | fn multiple_additions() { |
61 | | - let command = "What is 1 plus 1 plus 1?"; |
62 | | - assert_eq!(Some(3), answer(command)); |
| 75 | + let input = "What is 1 plus 1 plus 1?"; |
| 76 | + let output = wordy::answer(input); |
| 77 | + let expected = Some(3); |
| 78 | + assert_eq!(output, expected); |
63 | 79 | } |
64 | 80 |
|
65 | 81 | #[test] |
66 | 82 | #[ignore] |
67 | 83 | fn addition_and_subtraction() { |
68 | | - let command = "What is 1 plus 5 minus -2?"; |
69 | | - assert_eq!(Some(8), answer(command)); |
| 84 | + let input = "What is 1 plus 5 minus -2?"; |
| 85 | + let output = wordy::answer(input); |
| 86 | + let expected = Some(8); |
| 87 | + assert_eq!(output, expected); |
70 | 88 | } |
71 | 89 |
|
72 | 90 | #[test] |
73 | 91 | #[ignore] |
74 | 92 | fn multiple_subtraction() { |
75 | | - let command = "What is 20 minus 4 minus 13?"; |
76 | | - assert_eq!(Some(3), answer(command)); |
| 93 | + let input = "What is 20 minus 4 minus 13?"; |
| 94 | + let output = wordy::answer(input); |
| 95 | + let expected = Some(3); |
| 96 | + assert_eq!(output, expected); |
77 | 97 | } |
78 | 98 |
|
79 | 99 | #[test] |
80 | 100 | #[ignore] |
81 | 101 | fn subtraction_then_addition() { |
82 | | - let command = "What is 17 minus 6 plus 3?"; |
83 | | - assert_eq!(Some(14), answer(command)); |
| 102 | + let input = "What is 17 minus 6 plus 3?"; |
| 103 | + let output = wordy::answer(input); |
| 104 | + let expected = Some(14); |
| 105 | + assert_eq!(output, expected); |
84 | 106 | } |
85 | 107 |
|
86 | 108 | #[test] |
87 | 109 | #[ignore] |
88 | | -fn multiple_multiplications() { |
89 | | - let command = "What is 2 multiplied by -2 multiplied by 3?"; |
90 | | - assert_eq!(Some(-12), answer(command)); |
| 110 | +fn multiple_multiplication() { |
| 111 | + let input = "What is 2 multiplied by -2 multiplied by 3?"; |
| 112 | + let output = wordy::answer(input); |
| 113 | + let expected = Some(-12); |
| 114 | + assert_eq!(output, expected); |
91 | 115 | } |
92 | 116 |
|
93 | 117 | #[test] |
94 | 118 | #[ignore] |
95 | 119 | fn addition_and_multiplication() { |
96 | | - let command = "What is -3 plus 7 multiplied by -2?"; |
97 | | - assert_eq!(Some(-8), answer(command)); |
| 120 | + let input = "What is -3 plus 7 multiplied by -2?"; |
| 121 | + let output = wordy::answer(input); |
| 122 | + let expected = Some(-8); |
| 123 | + assert_eq!(output, expected); |
98 | 124 | } |
99 | 125 |
|
100 | 126 | #[test] |
101 | 127 | #[ignore] |
102 | | -fn multiple_divisions() { |
103 | | - let command = "What is -12 divided by 2 divided by -3?"; |
104 | | - assert_eq!(Some(2), answer(command)); |
| 128 | +fn multiple_division() { |
| 129 | + let input = "What is -12 divided by 2 divided by -3?"; |
| 130 | + let output = wordy::answer(input); |
| 131 | + let expected = Some(2); |
| 132 | + assert_eq!(output, expected); |
105 | 133 | } |
106 | 134 |
|
107 | 135 | #[test] |
108 | 136 | #[ignore] |
109 | 137 | fn unknown_operation() { |
110 | | - let command = "What is 52 cubed?"; |
111 | | - assert_eq!(None, answer(command)); |
| 138 | + let input = "What is 52 cubed?"; |
| 139 | + let output = wordy::answer(input); |
| 140 | + let expected = None; |
| 141 | + assert_eq!(output, expected); |
112 | 142 | } |
113 | 143 |
|
114 | 144 | #[test] |
115 | 145 | #[ignore] |
116 | 146 | fn non_math_question() { |
117 | | - let command = "Who is the President of the United States?"; |
118 | | - assert_eq!(None, answer(command)); |
| 147 | + let input = "Who is the President of the United States?"; |
| 148 | + let output = wordy::answer(input); |
| 149 | + let expected = None; |
| 150 | + assert_eq!(output, expected); |
119 | 151 | } |
120 | 152 |
|
121 | 153 | #[test] |
122 | 154 | #[ignore] |
123 | 155 | fn reject_problem_missing_an_operand() { |
124 | | - let command = "What is 1 plus?"; |
125 | | - assert_eq!(None, answer(command)); |
| 156 | + let input = "What is 1 plus?"; |
| 157 | + let output = wordy::answer(input); |
| 158 | + let expected = None; |
| 159 | + assert_eq!(output, expected); |
126 | 160 | } |
127 | 161 |
|
128 | 162 | #[test] |
129 | 163 | #[ignore] |
130 | 164 | fn reject_problem_with_no_operands_or_operators() { |
131 | | - let command = "What is?"; |
132 | | - assert_eq!(None, answer(command)); |
| 165 | + let input = "What is?"; |
| 166 | + let output = wordy::answer(input); |
| 167 | + let expected = None; |
| 168 | + assert_eq!(output, expected); |
133 | 169 | } |
134 | 170 |
|
135 | 171 | #[test] |
136 | 172 | #[ignore] |
137 | 173 | fn reject_two_operations_in_a_row() { |
138 | | - let command = "What is 1 plus plus 2?"; |
139 | | - assert_eq!(None, answer(command)); |
| 174 | + let input = "What is 1 plus plus 2?"; |
| 175 | + let output = wordy::answer(input); |
| 176 | + let expected = None; |
| 177 | + assert_eq!(output, expected); |
140 | 178 | } |
141 | 179 |
|
142 | 180 | #[test] |
143 | 181 | #[ignore] |
144 | 182 | fn reject_two_numbers_in_a_row() { |
145 | | - let command = "What is 1 plus 2 1?"; |
146 | | - assert_eq!(None, answer(command)); |
| 183 | + let input = "What is 1 plus 2 1?"; |
| 184 | + let output = wordy::answer(input); |
| 185 | + let expected = None; |
| 186 | + assert_eq!(output, expected); |
147 | 187 | } |
148 | 188 |
|
149 | 189 | #[test] |
150 | 190 | #[ignore] |
151 | 191 | fn reject_postfix_notation() { |
152 | | - let command = "What is 1 2 plus?"; |
153 | | - assert_eq!(None, answer(command)); |
| 192 | + let input = "What is 1 2 plus?"; |
| 193 | + let output = wordy::answer(input); |
| 194 | + let expected = None; |
| 195 | + assert_eq!(output, expected); |
154 | 196 | } |
155 | 197 |
|
156 | 198 | #[test] |
157 | 199 | #[ignore] |
158 | 200 | fn reject_prefix_notation() { |
159 | | - let command = "What is plus 1 2?"; |
160 | | - assert_eq!(None, answer(command)); |
| 201 | + let input = "What is plus 1 2?"; |
| 202 | + let output = wordy::answer(input); |
| 203 | + let expected = None; |
| 204 | + assert_eq!(output, expected); |
161 | 205 | } |
162 | 206 |
|
163 | 207 | #[test] |
164 | 208 | #[ignore] |
165 | 209 | #[cfg(feature = "exponentials")] |
166 | 210 | fn exponential() { |
167 | | - let command = "What is 2 raised to the 5th power?"; |
168 | | - assert_eq!(Some(32), answer(command)); |
| 211 | + let input = "What is 2 raised to the 5th power?"; |
| 212 | + let output = wordy::answer(input); |
| 213 | + let expected = Some(32); |
| 214 | + assert_eq!(output, expected); |
169 | 215 | } |
170 | 216 |
|
171 | 217 | #[test] |
172 | 218 | #[ignore] |
173 | 219 | #[cfg(feature = "exponentials")] |
174 | 220 | fn addition_and_exponential() { |
175 | | - let command = "What is 1 plus 2 raised to the 2nd power?"; |
176 | | - assert_eq!(Some(9), answer(command)); |
| 221 | + let input = "What is 1 plus 2 raised to the 2nd power?"; |
| 222 | + let output = wordy::answer(input); |
| 223 | + let expected = Some(9); |
| 224 | + assert_eq!(output, expected); |
177 | 225 | } |
0 commit comments