Skip to content

Commit 4d07e88

Browse files
committed
fixup! f7c438 Add a test for unique_masks, update docs
1 parent f7c4383 commit 4d07e88

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

libm/src/math/support/feature_detect.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Helpers for runtime target feature detection.
1+
//! Helpers for runtime target feature detection that are shared across architectures.
22
33
use core::sync::atomic::{AtomicU32, Ordering};
44

@@ -147,6 +147,21 @@ pub fn get_or_init_flags_cache(cache: &AtomicU32, init: impl FnOnce() -> Flags)
147147
mod tests {
148148
use super::*;
149149

150+
#[test]
151+
fn unique_masks() {
152+
unique_masks! {
153+
u32,
154+
V0,
155+
V1,
156+
V2,
157+
}
158+
assert_eq!(V0, 1u32 << 0);
159+
assert_eq!(V1, 1u32 << 1);
160+
assert_eq!(V2, 1u32 << 2);
161+
assert_eq!(ALL, [V0, V1, V2]);
162+
assert_eq!(NAMES, ["V0", "V1", "V2"]);
163+
}
164+
150165
#[test]
151166
fn flag_cache_is_used() {
152167
// Sanity check that flags are only ever set once

0 commit comments

Comments
 (0)