modes:mod: implemented a generic tester for non_reflexivity
Given two "Hands", we test that the footstool condition on those two hands are non-reflexive.
This commit is contained in:
@@ -11,3 +11,22 @@ pub enum Footstool {
|
||||
pub trait Hand {
|
||||
fn footstool(&self, other: Self) -> Footstool;
|
||||
}
|
||||
|
||||
mod tests {
|
||||
use super::*;
|
||||
pub fn test_non_reflexivity<T: Hand + Copy>(
|
||||
x: &T,
|
||||
y: &T,
|
||||
) -> (Footstool, Footstool) {
|
||||
let res1 = x.footstool(*y);
|
||||
let res2 = y.footstool(*x);
|
||||
assert!(match (res1, res2) {
|
||||
(Footstool::None, Footstool::None)
|
||||
| (Footstool::None, Footstool::Half)
|
||||
| (Footstool::Half, Footstool::None)
|
||||
| (Footstool::Full, Footstool::Full) => true,
|
||||
_ => false,
|
||||
});
|
||||
(res1, res2)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user