Sha256: f4a055d1f3c86decef70ef8f3020cef5c4e229718c20b3d59d5a3abc3a8b1298

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

use super::*;

use crate::Flags;

#[test]
fn cases() {
    case(Some(1), "A", TestFlags::from_name);
    case(Some(1 << 1), "B", TestFlags::from_name);
    case(Some(1 | 1 << 1 | 1 << 2), "ABC", TestFlags::from_name);

    case(None, "", TestFlags::from_name);
    case(None, "a", TestFlags::from_name);
    case(None, "0x1", TestFlags::from_name);
    case(None, "A | B", TestFlags::from_name);

    case(Some(0), "ZERO", TestZero::from_name);

    case(Some(2), "二", TestUnicode::from_name);

    case(None, "_", TestExternal::from_name);

    case(None, "", TestExternal::from_name);
}

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

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/from_name.rs
wasmtime-28.0.0 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/from_name.rs
wasmtime-27.0.0 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/from_name.rs
wasmtime-26.0.0 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/from_name.rs
wasmtime-25.0.2 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/from_name.rs
wasmtime-25.0.1 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/from_name.rs
wasmtime-25.0.0 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/from_name.rs
wasmtime-24.0.0 ./ext/cargo-vendor/bitflags-2.6.0/src/tests/from_name.rs