Skip to content

Commit 945da47

Browse files
authored
Add tests for subnormals consts (#209)
Signed-off-by: GitHub <[email protected]>
1 parent 64f365b commit 945da47

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

typed_floats/src/lib.rs

+24-9
Original file line numberDiff line numberDiff line change
@@ -881,14 +881,29 @@ mod tests {
881881

882882
#[test]
883883
fn test_subnormals() {
884-
assert!(tf64::MIN_SUBNORMAL_POSITIVE.is_subnormal());
885-
assert!(tf64::MAX_SUBNORMAL_POSITIVE.is_subnormal());
886-
assert!(tf64::MIN_SUBNORMAL_NEGATIVE.is_subnormal());
887-
assert!(tf64::MAX_SUBNORMAL_NEGATIVE.is_subnormal());
888-
889-
assert!(tf32::MIN_SUBNORMAL_POSITIVE.is_subnormal());
890-
assert!(tf32::MAX_SUBNORMAL_POSITIVE.is_subnormal());
891-
assert!(tf32::MIN_SUBNORMAL_NEGATIVE.is_subnormal());
892-
assert!(tf32::MAX_SUBNORMAL_NEGATIVE.is_subnormal());
884+
const SUBNORMALS_F64 : [f64; 4] = [
885+
tf64::MAX_SUBNORMAL_NEGATIVE.get(),
886+
tf64::MIN_SUBNORMAL_NEGATIVE.get(),
887+
tf64::MIN_SUBNORMAL_POSITIVE.get(),
888+
tf64::MAX_SUBNORMAL_POSITIVE.get(),
889+
];
890+
891+
const SUBNORMALS_F32 : [f32; 4] = [
892+
tf32::MAX_SUBNORMAL_NEGATIVE.get(),
893+
tf32::MIN_SUBNORMAL_NEGATIVE.get(),
894+
tf32::MIN_SUBNORMAL_POSITIVE.get(),
895+
tf32::MAX_SUBNORMAL_POSITIVE.get(),
896+
];
897+
898+
assert_sorted(&SUBNORMALS_F64, 0.0);
899+
assert_sorted(&SUBNORMALS_F32, 0.0);
900+
901+
for value in SUBNORMALS_F64 {
902+
assert!(value.is_subnormal());
903+
}
904+
905+
for value in SUBNORMALS_F32 {
906+
assert!(value.is_subnormal());
907+
}
893908
}
894909
}

0 commit comments

Comments
 (0)