1 use super::*;
2 
3 use crate::Flags;
4 
5 #[test]
cases()6 fn cases() {
7     case(0, TestFlags::empty(), TestFlags::bits);
8 
9     case(1, TestFlags::A, TestFlags::bits);
10     case(1 | 1 << 1 | 1 << 2, TestFlags::ABC, TestFlags::bits);
11 
12     case(!0, TestFlags::from_bits_retain(u8::MAX), TestFlags::bits);
13     case(1 << 3, TestFlags::from_bits_retain(1 << 3), TestFlags::bits);
14 
15     case(1 << 3, TestZero::from_bits_retain(1 << 3), TestZero::bits);
16 
17     case(1 << 3, TestEmpty::from_bits_retain(1 << 3), TestEmpty::bits);
18 
19     case(
20         1 << 4 | 1 << 6,
21         TestExternal::from_bits_retain(1 << 4 | 1 << 6),
22         TestExternal::bits,
23     );
24 }
25 
26 #[track_caller]
case<T: Flags + std::fmt::Debug>( expected: T::Bits, value: T, inherent: impl FnOnce(&T) -> T::Bits, ) where T::Bits: std::fmt::Debug + PartialEq,27 fn case<T: Flags + std::fmt::Debug>(
28     expected: T::Bits,
29     value: T,
30     inherent: impl FnOnce(&T) -> T::Bits,
31 ) where
32     T::Bits: std::fmt::Debug + PartialEq,
33 {
34     assert_eq!(expected, inherent(&value), "{:?}.bits()", value);
35     assert_eq!(expected, Flags::bits(&value), "Flags::bits({:?})", value);
36 }
37