aboutsummaryrefslogtreecommitdiff
path: root/bitflags/test_suite/tests/i128_bitflags.rs
blob: 1b6f7c586de7cbb7abbcd8004793e31f0ba2676c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#![cfg(feature = "unstable")]

#[macro_use]
extern crate bitflags;

bitflags! {
    /// baz
    struct Flags128: u128 {
        const A = 0x0000_0000_0000_0000_0000_0000_0000_0001;
        const B = 0x0000_0000_0000_1000_0000_0000_0000_0000;
        const C = 0x8000_0000_0000_0000_0000_0000_0000_0000;
        const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
    }
}

#[test]
fn test_i128_bitflags() {
    assert_eq!(Flags128::ABC, Flags128::A | Flags128::B | Flags128::C);
    assert_eq!(Flags128::A.bits, 0x0000_0000_0000_0000_0000_0000_0000_0001);
    assert_eq!(Flags128::B.bits, 0x0000_0000_0000_1000_0000_0000_0000_0000);
    assert_eq!(Flags128::C.bits, 0x8000_0000_0000_0000_0000_0000_0000_0000);
    assert_eq!(
        Flags128::ABC.bits,
        0x8000_0000_0000_1000_0000_0000_0000_0001
    );
    assert_eq!(format!("{:?}", Flags128::A), "A");
    assert_eq!(format!("{:?}", Flags128::B), "B");
    assert_eq!(format!("{:?}", Flags128::C), "C");
    assert_eq!(format!("{:?}", Flags128::ABC), "A | B | C | ABC");
}