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/intersection.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 / intersection.rs` 79 lines ยท 1804 bytes Raw Blame History 1 use super::*; 2 3 use crate::Flags; 4 5 #[test] 6 fn cases() { 7 case( 8 TestFlags::empty(), 9 &[(TestFlags::empty(), 0), (TestFlags::all(), 0)], 10 TestFlags::intersection, 11 ); 12 13 case( 14 TestFlags::all(), 15 &[ 16 (TestFlags::all(), 1 | 1 << 1 | 1 << 2), 17 (TestFlags::A, 1), 18 (TestFlags::from_bits_retain(1 << 3), 0), 19 ], 20 TestFlags::intersection, 21 ); 22 23 case( 24 TestFlags::from_bits_retain(1 << 3), 25 &[(TestFlags::from_bits_retain(1 << 3), 1 << 3)], 26 TestFlags::intersection, 27 ); 28 29 case( 30 TestOverlapping::AB, 31 &[(TestOverlapping::BC, 1 << 1)], 32 TestOverlapping::intersection, 33 ); 34 } 35 36 #[track_caller] 37 fn case + std::ops::BitAndAssign + Copy>( 38 value: T, 39 inputs: &[(T, T::Bits)], 40 mut inherent: impl FnMut(T, T) -> T, 41 ) where 42 T::Bits: std::fmt::Debug + PartialEq + Copy, 43 { 44 for (input, expected) in inputs { 45 assert_eq!( 46 *expected, 47 inherent(value, *input).bits(), 48 "{:?}.intersection({:?})", 49 value, 50 input 51 ); 52 assert_eq!( 53 *expected, 54 Flags::intersection(value, *input).bits(), 55 "Flags::intersection({:?}, {:?})", 56 value, 57 input 58 ); 59 assert_eq!( 60 *expected, 61 (value & *input).bits(), 62 "{:?} & {:?}", 63 value, 64 input 65 ); 66 assert_eq!( 67 *expected, 68 { 69 let mut value = value; 70 value &= *input; 71 value 72 } 73 .bits(), 74 "{:?} &= {:?}", 75 value, 76 input, 77 ); 78 } 79 }