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/intersects.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 / intersects.rs` 91 lines ยท 2201 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::empty(), false), 11 (TestFlags::A, false), 12 (TestFlags::B, false), 13 (TestFlags::C, false), 14 (TestFlags::from_bits_retain(1 << 3), false), 15 ], 16 TestFlags::intersects, 17 ); 18 19 case( 20 TestFlags::A, 21 &[ 22 (TestFlags::empty(), false), 23 (TestFlags::A, true), 24 (TestFlags::B, false), 25 (TestFlags::C, false), 26 (TestFlags::ABC, true), 27 (TestFlags::from_bits_retain(1 << 3), false), 28 (TestFlags::from_bits_retain(1 | (1 << 3)), true), 29 ], 30 TestFlags::intersects, 31 ); 32 33 case( 34 TestFlags::ABC, 35 &[ 36 (TestFlags::empty(), false), 37 (TestFlags::A, true), 38 (TestFlags::B, true), 39 (TestFlags::C, true), 40 (TestFlags::ABC, true), 41 (TestFlags::from_bits_retain(1 << 3), false), 42 ], 43 TestFlags::intersects, 44 ); 45 46 case( 47 TestFlags::from_bits_retain(1 << 3), 48 &[ 49 (TestFlags::empty(), false), 50 (TestFlags::A, false), 51 (TestFlags::B, false), 52 (TestFlags::C, false), 53 (TestFlags::from_bits_retain(1 << 3), true), 54 ], 55 TestFlags::intersects, 56 ); 57 58 case( 59 TestOverlapping::AB, 60 &[ 61 (TestOverlapping::AB, true), 62 (TestOverlapping::BC, true), 63 (TestOverlapping::from_bits_retain(1 << 1), true), 64 ], 65 TestOverlapping::intersects, 66 ); 67 } 68 69 #[track_caller] 70 fn case( 71 value: T, 72 inputs: &[(T, bool)], 73 mut inherent: impl FnMut(&T, T) -> bool, 74 ) { 75 for (input, expected) in inputs { 76 assert_eq!( 77 *expected, 78 inherent(&value, *input), 79 "{:?}.intersects({:?})", 80 value, 81 input 82 ); 83 assert_eq!( 84 *expected, 85 Flags::intersects(&value, *input), 86 "Flags::intersects({:?}, {:?})", 87 value, 88 input 89 ); 90 } 91 }