summaryrefslogtreecommitdiffstats
path: root/third_party/rust/bitflags/src/tests/extend.rs
blob: 869dc17fc81b6125f908e57caff51866e89fec47 (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
31
32
33
34
35
36
37
38
39
40
41
42
use super::*;

#[test]
fn cases() {
    let mut flags = TestFlags::empty();

    flags.extend(TestFlags::A);

    assert_eq!(TestFlags::A, flags);

    flags.extend(TestFlags::A | TestFlags::B | TestFlags::C);

    assert_eq!(TestFlags::ABC, flags);

    flags.extend(TestFlags::from_bits_retain(1 << 5));

    assert_eq!(TestFlags::ABC | TestFlags::from_bits_retain(1 << 5), flags);
}

mod external {
    use super::*;

    #[test]
    fn cases() {
        let mut flags = TestExternal::empty();

        flags.extend(TestExternal::A);

        assert_eq!(TestExternal::A, flags);

        flags.extend(TestExternal::A | TestExternal::B | TestExternal::C);

        assert_eq!(TestExternal::ABC, flags);

        flags.extend(TestExternal::from_bits_retain(1 << 5));

        assert_eq!(
            TestExternal::ABC | TestExternal::from_bits_retain(1 << 5),
            flags
        );
    }
}