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