Skip to content

Commit

Permalink
add test_zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
mo271 committed Nov 18, 2024
1 parent 274da96 commit 54b7e7b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/pattern-matching/exercise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,34 @@ fn test_recursion() {
);
}

#[test]
fn test_zeros() {
assert_eq!(
eval(Expression::Op {
op: Operation::Add,
left: Box::new(Expression::Value(0)),
right: Box::new(Expression::Value(0))
}),
Ok(0)
);
assert_eq!(
eval(Expression::Op {
op: Operation::Mul,
left: Box::new(Expression::Value(0)),
right: Box::new(Expression::Value(0))
}),
Ok(0)
);
assert_eq!(
eval(Expression::Op {
op: Operation::Sub,
left: Box::new(Expression::Value(0)),
right: Box::new(Expression::Value(0))
}),
Ok(0)
);
}

#[test]
fn test_error() {
assert_eq!(
Expand Down

0 comments on commit 54b7e7b

Please sign in to comment.