summaryrefslogtreecommitdiffstats
path: root/third_party/rust/bitflags/src/tests/is_empty.rs
blob: 92165f18e36bf05ea7e580c3fe12b62836ee1adb (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
use super::*;

use crate::Flags;

#[test]
fn cases() {
    case(true, TestFlags::empty(), TestFlags::is_empty);

    case(false, TestFlags::A, TestFlags::is_empty);
    case(false, TestFlags::ABC, TestFlags::is_empty);
    case(
        false,
        TestFlags::from_bits_retain(1 << 3),
        TestFlags::is_empty,
    );

    case(true, TestZero::empty(), TestZero::is_empty);

    case(true, TestEmpty::empty(), TestEmpty::is_empty);
}

#[track_caller]
fn case<T: Flags + std::fmt::Debug>(expected: bool, value: T, inherent: impl FnOnce(&T) -> bool) {
    assert_eq!(expected, inherent(&value), "{:?}.is_empty()", value);
    assert_eq!(
        expected,
        Flags::is_empty(&value),
        "Flags::is_empty({:?})",
        value
    );
}