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/fmt.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 / fmt.rs` 97 lines ยท 1971 bytes Raw Blame History 1 use super::*; 2 3 #[test] 4 fn cases() { 5 case(TestFlags::empty(), "TestFlags(0x0)", "0", "0", "0", "0"); 6 case(TestFlags::A, "TestFlags(A)", "1", "1", "1", "1"); 7 case( 8 TestFlags::all(), 9 "TestFlags(A | B | C)", 10 "7", 11 "7", 12 "7", 13 "111", 14 ); 15 case( 16 TestFlags::from_bits_retain(1 << 3), 17 "TestFlags(0x8)", 18 "8", 19 "8", 20 "10", 21 "1000", 22 ); 23 case( 24 TestFlags::A | TestFlags::from_bits_retain(1 << 3), 25 "TestFlags(A | 0x8)", 26 "9", 27 "9", 28 "11", 29 "1001", 30 ); 31 32 case(TestZero::ZERO, "TestZero(0x0)", "0", "0", "0", "0"); 33 case( 34 TestZero::ZERO | TestZero::from_bits_retain(1), 35 "TestZero(0x1)", 36 "1", 37 "1", 38 "1", 39 "1", 40 ); 41 42 case(TestZeroOne::ONE, "TestZeroOne(ONE)", "1", "1", "1", "1"); 43 44 case( 45 TestOverlapping::from_bits_retain(1 << 1), 46 "TestOverlapping(0x2)", 47 "2", 48 "2", 49 "2", 50 "10", 51 ); 52 53 case( 54 TestExternal::from_bits_retain(1 | 1 << 1 | 1 << 3), 55 "TestExternal(A | B | 0x8)", 56 "B", 57 "b", 58 "13", 59 "1011", 60 ); 61 62 case( 63 TestExternal::all(), 64 "TestExternal(A | B | C | 0xf8)", 65 "FF", 66 "ff", 67 "377", 68 "`11111111`", 69 ); 70 71 case( 72 TestExternalFull::all(), 73 "TestExternalFull(0xff)", 74 "FF", 75 "ff", 76 "377", 77 "`11111111`", 78 ); 79 } 80 81 #[track_caller] 82 fn case< 83 T: std::fmt::Debug + std::fmt::UpperHex + std::fmt::LowerHex + std::fmt::Octal + std::fmt::Binary, 84 >( 85 value: T, 86 debug: &str, 87 uhex: &str, 88 lhex: &str, 89 oct: &str, 90 bin: &str, 91 ) { 92 assert_eq!(debug, format!("{:?}", value)); 93 assert_eq!(uhex, format!("{:X}", value)); 94 assert_eq!(lhex, format!("{:x}", value)); 95 assert_eq!(oct, format!("{:o}", value)); 96 assert_eq!(bin, format!("{:b}", value)); 97 }