Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/bitflags/src/tests/from_bits.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / bitflags / src / tests / from_bits.rs` 45 lines ยท 1006 bytes Raw Blame History 1 use super::*; 2 3 use crate::Flags; 4 5 #[test] 6 fn cases() { 7 case(Some(0), 0, TestFlags::from_bits); 8 case(Some(1), 1, TestFlags::from_bits); 9 case( 10 Some(1 | 1 << 1 | 1 << 2), 11 1 | 1 << 1 | 1 << 2, 12 TestFlags::from_bits, 13 ); 14 15 case(None, 1 << 3, TestFlags::from_bits); 16 case(None, 1 | 1 << 3, TestFlags::from_bits); 17 18 case(Some(1 | 1 << 1), 1 | 1 << 1, TestOverlapping::from_bits); 19 20 case(Some(1 << 1), 1 << 1, TestOverlapping::from_bits); 21 22 case(Some(1 << 5), 1 << 5, TestExternal::from_bits); 23 } 24 25 #[track_caller] 26 fn case( 27 expected: Option, 28 input: T::Bits, 29 inherent: impl FnOnce(T::Bits) -> Option, 30 ) where 31 ::Bits: std::fmt::Debug + PartialEq, 32 { 33 assert_eq!( 34 expected, 35 inherent(input).map(|f| f.bits()), 36 "T::from_bits({:?})", 37 input 38 ); 39 assert_eq!( 40 expected, 41 T::from_bits(input).map(|f| f.bits()), 42 "Flags::from_bits({:?})", 43 input 44 ); 45 }