Skip to content

Commit 3f94742

Browse files
Unify and deduplicate From<bool> float tests
cc #141726 Unify the From<bool> tests from f16.rs and f128.rs into a single float_test! in mod.rs.
1 parent bf6b5b9 commit 3f94742

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

library/coretests/tests/floats/f128.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ const TOL_PRECISE: f128 = 1e-28;
2020

2121
#[test]
2222
fn test_from() {
23-
assert_biteq!(f128::from(false), 0.0);
24-
assert_biteq!(f128::from(true), 1.0);
2523
assert_biteq!(f128::from(u8::MIN), 0.0);
2624
assert_biteq!(f128::from(42_u8), 42.0);
2725
assert_biteq!(f128::from(u8::MAX), 255.0);

library/coretests/tests/floats/f16.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ const TOL_P4: f16 = 10.0;
2424

2525
#[test]
2626
fn test_from() {
27-
assert_biteq!(f16::from(false), 0.0);
28-
assert_biteq!(f16::from(true), 1.0);
2927
assert_biteq!(f16::from(u8::MIN), 0.0);
3028
assert_biteq!(f16::from(42_u8), 42.0);
3129
assert_biteq!(f16::from(u8::MAX), 255.0);

library/coretests/tests/floats/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,3 +1582,15 @@ float_test! {
15821582
assert_biteq!((flt(-3.2)).mul_add(2.4, neg_inf), neg_inf);
15831583
}
15841584
}
1585+
1586+
float_test! {
1587+
name: from_bool,
1588+
attrs: {
1589+
f16: #[cfg(any(miri, target_has_reliable_f16))],
1590+
f128: #[cfg(any(miri, target_has_reliable_f128))],
1591+
},
1592+
test<Float> {
1593+
assert_biteq!(Float::from(false), Float::ZERO);
1594+
assert_biteq!(Float::from(true), Float::ONE);
1595+
}
1596+
}

0 commit comments

Comments
 (0)