interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / bitflags / src / tests / known_bits.rs

47 lines · 1032 bytes Raw Blame History
1use super::*;
2
3use crate::Flags;
4
5#[test]
6fn cases() {
7 case(0, TestFlags::empty(), TestFlags::known_bits);
8 case(1, TestFlags::A, TestFlags::known_bits);
9 case(1 | 1 << 1 | 1 << 2, TestFlags::all(), TestFlags::known_bits);
10
11 case(
12 1 | 1 << 1 | 1 << 2,
13 TestFlags::ABC | TestFlags::from_bits_retain(1 << 3),
14 TestFlags::known_bits,
15 );
16
17 case(
18 0,
19 TestFlags::from_bits_retain(1 << 3),
20 TestFlags::known_bits,
21 );
22
23 case(0, TestZero::empty(), TestZero::known_bits);
24
25 case(
26 0xFF,
27 TestExternal::from_bits_retain(0xFF),
28 TestExternal::known_bits,
29 );
30}
31
32#[track_caller]
33fn case<T: Flags + std::fmt::Debug>(
34 expected: T::Bits,
35 value: T,
36 inherent: impl FnOnce(&T) -> T::Bits,
37) where
38 T::Bits: std::fmt::Debug + PartialEq,
39{
40 assert_eq!(expected, inherent(&value), "{:?}.known_bits()", value);
41 assert_eq!(
42 expected,
43 Flags::known_bits(&value),
44 "Flags::known_bits({:?})",
45 value,
46 );
47}