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