mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-24 16:42:36 +02:00
Change tests for pattern-matching exercise (#2463)
to catch wrong `right == 0` checks. To change the number like this catches for example a wrong implementation only looking if `right_result` is zero, but not checking if we are doing a division.
This commit is contained in:
parent
7f59978a0a
commit
6148caed7a
@ -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]
|
#[test]
|
||||||
fn test_error() {
|
fn test_error() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user