aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaximilian Bosch <[email protected]>2019-12-05 13:38:54 +0000
committerMaximilian Bosch <[email protected]>2019-12-05 13:38:54 +0000
commitcacf51dbb9748b1dbe97b35f3c593a0a272bd4db (patch)
treef6a60c286e16b23caeb1083e5f959517d562ca20 /src
parent6ce0fc0212a34ffb647b24d9d903029ac4518165 (diff)
Fix tests
`eval_math_expression` expects `std::option::Option<f64>` rather than `f64`.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index 63b07c9..d241b58 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -202,42 +202,42 @@ mod tests {
202 202
203 #[test] 203 #[test]
204 fn basic_ops() { 204 fn basic_ops() {
205 let evaled = eval_math_expression("6*2 + 3 + 12 -3", 0f64).unwrap(); 205 let evaled = eval_math_expression("6*2 + 3 + 12 -3", Some(0f64)).unwrap();
206 assert_eq!(24., evaled); 206 assert_eq!(24., evaled);
207 } 207 }
208 #[test] 208 #[test]
209 fn trignometric_fns() { 209 fn trignometric_fns() {
210 let evaled = eval_math_expression("sin(30) + tan(45", 0f64).unwrap(); 210 let evaled = eval_math_expression("sin(30) + tan(45", Some(0f64)).unwrap();
211 assert_eq!(1.5, evaled); 211 assert_eq!(1.5, evaled);
212 } 212 }
213 #[test] 213 #[test]
214 fn brackets() { 214 fn brackets() {
215 let evaled = eval_math_expression("(((1 + 2 + 3) ^ 2 ) - 4)", 0f64).unwrap(); 215 let evaled = eval_math_expression("(((1 + 2 + 3) ^ 2 ) - 4)", Some(0f64)).unwrap();
216 assert_eq!(32., evaled); 216 assert_eq!(32., evaled);
217 } 217 }
218 #[test] 218 #[test]
219 fn floating_ops() { 219 fn floating_ops() {
220 let evaled = eval_math_expression("1.2816 + 1 + 1.2816/1.2", 0f64).unwrap(); 220 let evaled = eval_math_expression("1.2816 + 1 + 1.2816/1.2", Some(0f64)).unwrap();
221 assert_eq!(3.3496, evaled); 221 assert_eq!(3.3496, evaled);
222 } 222 }
223 #[test] 223 #[test]
224 fn inverse_trignometric_fns() { 224 fn inverse_trignometric_fns() {
225 let evaled = eval_math_expression("deg(asin(1) + acos(1))", 0f64).unwrap(); 225 let evaled = eval_math_expression("deg(asin(1) + acos(1))", Some(0f64)).unwrap();
226 assert_eq!(90., evaled); 226 assert_eq!(90., evaled);
227 } 227 }
228 #[test] 228 #[test]
229 fn sigmoid_fns() { 229 fn sigmoid_fns() {
230 let evaled = eval_math_expression("1 / (1 + e^-7)", 0f64).unwrap(); 230 let evaled = eval_math_expression("1 / (1 + e^-7)", Some(0f64)).unwrap();
231 assert_eq!(0.9990889488, evaled); 231 assert_eq!(0.9990889488, evaled);
232 } 232 }
233 #[test] 233 #[test]
234 fn prev_ans() { 234 fn prev_ans() {
235 let evaled = eval_math_expression("_ + 9", 9f64).unwrap(); 235 let evaled = eval_math_expression("_ + 9", Some(9f64)).unwrap();
236 assert_eq!(18.0, evaled); 236 assert_eq!(18.0, evaled);
237 } 237 }
238 #[test] 238 #[test]
239 fn eval_with_zero_prev() { 239 fn eval_with_zero_prev() {
240 let evaled = eval_math_expression("9 + _ ", 0f64).unwrap(); 240 let evaled = eval_math_expression("9 + _ ", Some(0f64)).unwrap();
241 assert_eq!(9., evaled); 241 assert_eq!(9., evaled);
242 } 242 }
243} 243}