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