Add initial proptests
This commit is contained in:
parent
907691685c
commit
3ec2d34f65
7 changed files with 148 additions and 23 deletions
|
|
@ -75,6 +75,7 @@ impl Transformable for Direction {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::prelude::*;
|
||||
use proptest::{prop_assert_eq, proptest};
|
||||
|
||||
#[test]
|
||||
fn position() {
|
||||
|
|
@ -87,21 +88,16 @@ mod test {
|
|||
assert_eq!(p.transform(t), Position::new(-6, -10));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invert() {
|
||||
let transformations = [
|
||||
Transformation::new(Direction::Up, Position::new(-3, -5)),
|
||||
Transformation::new(Direction::Right, Position::new(-3, -5)),
|
||||
Transformation::new(Direction::Down, Position::new(-3, -5)),
|
||||
Transformation::new(Direction::Left, Position::new(-3, -5)),
|
||||
];
|
||||
proptest! {
|
||||
#[test]
|
||||
fn invert(dir: Direction, pos: Position) {
|
||||
let o = Transformation::new(dir, pos);
|
||||
|
||||
for o in transformations {
|
||||
let i = o.invert();
|
||||
let c = o.chain(i);
|
||||
|
||||
assert_eq!(c.rot, Direction::Up, "o: {:?}, i: {:?}, c: {:?}", o, i, c);
|
||||
assert_eq!(
|
||||
prop_assert_eq!(c.rot, Direction::Up, "o: {:?}, i: {:?}, c: {:?}", o, i, c);
|
||||
prop_assert_eq!(
|
||||
c.pos,
|
||||
Position::new(0, 0),
|
||||
"o: {:?}, i: {:?}, c: {:?}",
|
||||
|
|
@ -109,6 +105,7 @@ mod test {
|
|||
i,
|
||||
c
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue