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