Sha256: 3840c34b2ea5d1802404b9ce5bcc1d3fa6ccd8dfba2e29e6d07c605f817d90df

Contents?: true

Size: 958 Bytes

Versions: 8

Compression:

Stored size: 958 Bytes

Contents

use super::*;

use crate::Flags;

#[test]
fn cases() {
    case(0, TestFlags::empty(), TestFlags::bits);

    case(1, TestFlags::A, TestFlags::bits);
    case(1 | 1 << 1 | 1 << 2, TestFlags::ABC, TestFlags::bits);

    case(!0, TestFlags::from_bits_retain(u8::MAX), TestFlags::bits);
    case(1 << 3, TestFlags::from_bits_retain(1 << 3), TestFlags::bits);

    case(1 << 3, TestZero::from_bits_retain(1 << 3), TestZero::bits);

    case(1 << 3, TestEmpty::from_bits_retain(1 << 3), TestEmpty::bits);

    case(
        1 << 4 | 1 << 6,
        TestExternal::from_bits_retain(1 << 4 | 1 << 6),
        TestExternal::bits,
    );
}

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/bitflags-2.8.0/src/tests/bits.rs
wasmtime-28.0.0 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/bits.rs
wasmtime-27.0.0 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/bits.rs
wasmtime-26.0.0 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/bits.rs
wasmtime-25.0.2 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/bits.rs
wasmtime-25.0.1 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/bits.rs
wasmtime-25.0.0 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/bits.rs
wasmtime-24.0.0 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/bits.rs