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/flag_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 / flag_name.rs` 40 lines ยท 1035 bytes Raw Blame History 1 use super::*; 2 3 use crate::{parser::*, Flags}; 4 5 #[test] 6 fn cases() { 7 let flags = TestRenamed::FLAGS 8 .iter() 9 .map(|flag| (flag.name(), flag.value().bits())) 10 .collect::>(); 11 12 assert_eq!( 13 vec![ 14 ("custom", 1), 15 ("custom", 1 << 1), 16 ("c", 1 << 2), 17 ("custom | e", 1 << 3), 18 ], 19 flags, 20 ); 21 22 // Original names are not recognized 23 assert!(TestRenamed::from_name("A").is_none()); 24 25 // Regular renames are recognized 26 assert_eq!(TestRenamed::C, TestRenamed::from_name("c").unwrap()); 27 28 // The first duplicate name is recognized 29 assert_eq!(TestRenamed::A, TestRenamed::from_name("custom").unwrap()); 30 31 // Exotic names are recognized 32 assert_eq!( 33 TestRenamed::D, 34 TestRenamed::from_name("custom | e").unwrap() 35 ); 36 37 // The parser doesn't have defined behavior on exotic names, but we 38 // make sure it does _something_ 39 assert!(from_str_truncate::("custom | e").is_err()); 40 }