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:
2026-04-02 05:39:08 +01:00
committed by oreodave
parent 9c5ee74639
commit bcd38ecdc4

View File

@@ -11,3 +11,22 @@ pub enum Footstool {
pub trait Hand { pub trait Hand {
fn footstool(&self, other: Self) -> Footstool; 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)
}
}