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_truncate.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_truncate.rs` 42 lines ยท 1010 bytes Raw Blame History 1 use super::*; 2 3 use crate::Flags; 4 5 #[test] 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] 26 fn case(expected: T::Bits, input: T::Bits, inherent: impl FnOnce(T::Bits) -> T) 27 where 28 ::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 }