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/from_name.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 / from_name.rs` 42 lines · 1035 bytes Raw Blame History 1 use super::*; 2 3 use crate::Flags; 4 5 #[test] 6 fn cases() { 7 case(Some(1), "A", TestFlags::from_name); 8 case(Some(1 << 1), "B", TestFlags::from_name); 9 case(Some(1 | 1 << 1 | 1 << 2), "ABC", TestFlags::from_name); 10 11 case(None, "", TestFlags::from_name); 12 case(None, "a", TestFlags::from_name); 13 case(None, "0x1", TestFlags::from_name); 14 case(None, "A | B", TestFlags::from_name); 15 16 case(Some(0), "ZERO", TestZero::from_name); 17 18 case(Some(2), "二", TestUnicode::from_name); 19 20 case(None, "_", TestExternal::from_name); 21 22 case(None, "", TestExternal::from_name); 23 } 24 25 #[track_caller] 26 fn case(expected: Option, input: &str, inherent: impl FnOnce(&str) -> Option) 27 where 28 ::Bits: std::fmt::Debug + PartialEq, 29 { 30 assert_eq!( 31 expected, 32 inherent(input).map(|f| f.bits()), 33 "T::from_name({:?})", 34 input 35 ); 36 assert_eq!( 37 expected, 38 T::from_name(input).map(|f| f.bits()), 39 "Flags::from_name({:?})", 40 input 41 ); 42 }