| 48 | |
| 49 | #[track_caller] |
| 50 | fn case<T: Flags + std::fmt::Debug + std::ops::Sub<Output = T> + std::ops::SubAssign + Copy>( |
| 51 | value: T, |
| 52 | inputs: &[(T, T::Bits)], |
| 53 | mut inherent: impl FnMut(T, T) -> T, |
| 54 | ) where |
| 55 | T::Bits: std::fmt::Debug + PartialEq + Copy, |
| 56 | { |
| 57 | for (input, expected) in inputs { |
| 58 | assert_eq!( |
| 59 | *expected, |
| 60 | inherent(value, *input).bits(), |
| 61 | "{:?}.difference({:?})", |
| 62 | value, |
| 63 | input |
| 64 | ); |
| 65 | assert_eq!( |
| 66 | *expected, |
| 67 | Flags::difference(value, *input).bits(), |
| 68 | "Flags::difference({:?}, {:?})", |
| 69 | value, |
| 70 | input |
| 71 | ); |
| 72 | assert_eq!( |
| 73 | *expected, |
| 74 | (value - *input).bits(), |
| 75 | "{:?} - {:?}", |
| 76 | value, |
| 77 | input |
| 78 | ); |
| 79 | assert_eq!( |
| 80 | *expected, |
| 81 | { |
| 82 | let mut value = value; |
| 83 | value -= *input; |
| 84 | value |
| 85 | } |
| 86 | .bits(), |
| 87 | "{:?} -= {:?}", |
| 88 | value, |
| 89 | input, |
| 90 | ); |
| 91 | } |
| 92 | } |