aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / bitflags / src / tests / from_bits_retain.rs
| 1 | use super::*; |
| 2 | |
| 3 | use crate::Flags; |
| 4 | |
| 5 | #[test] |
| 6 | fn cases() { |
| 7 | case(0, TestFlags::from_bits_retain); |
| 8 | case(1, TestFlags::from_bits_retain); |
| 9 | case(1 | 1 << 1 | 1 << 2, TestFlags::from_bits_retain); |
| 10 | |
| 11 | case(1 << 3, TestFlags::from_bits_retain); |
| 12 | case(1 | 1 << 3, TestFlags::from_bits_retain); |
| 13 | |
| 14 | case(1 | 1 << 1, TestOverlapping::from_bits_retain); |
| 15 | |
| 16 | case(1 << 1, TestOverlapping::from_bits_retain); |
| 17 | |
| 18 | case(1 << 5, TestExternal::from_bits_retain); |
| 19 | } |
| 20 | |
| 21 | #[track_caller] |
| 22 | fn case<T: Flags>(input: T::Bits, inherent: impl FnOnce(T::Bits) -> T) |
| 23 | where |
| 24 | <T as Flags>::Bits: std::fmt::Debug + PartialEq, |
| 25 | { |
| 26 | assert_eq!( |
| 27 | input, |
| 28 | inherent(input).bits(), |
| 29 | "T::from_bits_retain({:?})", |
| 30 | input |
| 31 | ); |
| 32 | assert_eq!( |
| 33 | input, |
| 34 | T::from_bits_retain(input).bits(), |
| 35 | "Flags::from_bits_retain({:?})", |
| 36 | input |
| 37 | ); |
| 38 | } |