diff --git a/tests/no_std.rs b/tests/no_std.rs new file mode 100644 index 0000000..313eba0 --- /dev/null +++ b/tests/no_std.rs @@ -0,0 +1,41 @@ +#![no_std] + +#[cfg(test)] +mod tests { + use bitmask_enum::bitmask; + + #[bitmask] + #[bitmask_config(inverted_flags, vec_debug)] + enum NoStdBitmask { + Flag1, + Flag2, + } + + #[bitmask(u8)] + #[bitmask_config(inverted_flags, vec_debug)] + enum NoStdBitmaskU8 { + Flag1, + Flag2, + } + + #[test] + fn test() { + let mut bm = NoStdBitmask::none(); + assert_eq!(bm, 0); + + bm |= NoStdBitmask::Flag1; + assert_eq!(bm, NoStdBitmask::Flag1); + + bm |= NoStdBitmask::InvertedFlag1; + assert_eq!(bm.is_all_bits(), true); + + let mut bm = NoStdBitmaskU8::none(); + assert_eq!(bm, 0); + + bm |= NoStdBitmaskU8::Flag1; + assert_eq!(bm, NoStdBitmaskU8::Flag1); + + bm |= NoStdBitmaskU8::InvertedFlag1; + assert_eq!(bm.is_all_bits(), true); + } +} \ No newline at end of file