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/complement.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 / complement.rs` 53 lines ยท 1324 bytes Raw Blame History 1 use super::*; 2 3 use crate::Flags; 4 5 #[test] 6 fn cases() { 7 case(0, TestFlags::all(), TestFlags::complement); 8 case(0, TestFlags::from_bits_retain(!0), TestFlags::complement); 9 10 case(1 | 1 << 1, TestFlags::C, TestFlags::complement); 11 case( 12 1 | 1 << 1, 13 TestFlags::C | TestFlags::from_bits_retain(1 << 3), 14 TestFlags::complement, 15 ); 16 17 case( 18 1 | 1 << 1 | 1 << 2, 19 TestFlags::empty(), 20 TestFlags::complement, 21 ); 22 case( 23 1 | 1 << 1 | 1 << 2, 24 TestFlags::from_bits_retain(1 << 3), 25 TestFlags::complement, 26 ); 27 28 case(0, TestZero::empty(), TestZero::complement); 29 30 case(0, TestEmpty::empty(), TestEmpty::complement); 31 32 case(1 << 2, TestOverlapping::AB, TestOverlapping::complement); 33 34 case(!0, TestExternal::empty(), TestExternal::complement); 35 } 36 37 #[track_caller] 38 fn case + Copy>( 39 expected: T::Bits, 40 value: T, 41 inherent: impl FnOnce(T) -> T, 42 ) where 43 T::Bits: std::fmt::Debug + PartialEq, 44 { 45 assert_eq!(expected, inherent(value).bits(), "{:?}.complement()", value); 46 assert_eq!( 47 expected, 48 Flags::complement(value).bits(), 49 "Flags::complement({:?})", 50 value 51 ); 52 assert_eq!(expected, (!value).bits(), "!{:?}", value); 53 }