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 / is_all.rs
| 1 | use super::*; |
| 2 | |
| 3 | use crate::Flags; |
| 4 | |
| 5 | #[test] |
| 6 | fn cases() { |
| 7 | case(false, TestFlags::empty(), TestFlags::is_all); |
| 8 | case(false, TestFlags::A, TestFlags::is_all); |
| 9 | |
| 10 | case(true, TestFlags::ABC, TestFlags::is_all); |
| 11 | |
| 12 | case( |
| 13 | true, |
| 14 | TestFlags::ABC | TestFlags::from_bits_retain(1 << 3), |
| 15 | TestFlags::is_all, |
| 16 | ); |
| 17 | |
| 18 | case(true, TestZero::empty(), TestZero::is_all); |
| 19 | |
| 20 | case(true, TestEmpty::empty(), TestEmpty::is_all); |
| 21 | } |
| 22 | |
| 23 | #[track_caller] |
| 24 | fn case<T: Flags + std::fmt::Debug>(expected: bool, value: T, inherent: impl FnOnce(&T) -> bool) { |
| 25 | assert_eq!(expected, inherent(&value), "{:?}.is_all()", value); |
| 26 | assert_eq!( |
| 27 | expected, |
| 28 | Flags::is_all(&value), |
| 29 | "Flags::is_all({:?})", |
| 30 | value |
| 31 | ); |
| 32 | } |