Skip to content

Commit

Permalink
added simple no_std test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas3674 committed Oct 22, 2024
1 parent 56a9073 commit d12cf68
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/no_std.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit d12cf68

Please sign in to comment.