Skip to content

Commit 2229986

Browse files
committed
Add clamp_to float tests
1 parent ee4bbf8 commit 2229986

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

  • library/coretests/tests/floats

library/coretests/tests/floats/mod.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,48 @@ float_test! {
12561256
}
12571257
}
12581258

1259+
float_test! {
1260+
name: clamp_to_min_greater_than_max,
1261+
attrs: {
1262+
const: #[cfg(false)],
1263+
f16: #[should_panic, cfg(any(miri, target_has_reliable_f16))],
1264+
f32: #[should_panic],
1265+
f64: #[should_panic],
1266+
f128: #[should_panic, cfg(any(miri, target_has_reliable_f128))],
1267+
},
1268+
test<Float> {
1269+
let _ = Float::ONE.clamp_to(3.0..=1.0);
1270+
}
1271+
}
1272+
1273+
float_test! {
1274+
name: clamp_to_min_is_nan,
1275+
attrs: {
1276+
const: #[cfg(false)],
1277+
f16: #[should_panic, cfg(any(miri, target_has_reliable_f16))],
1278+
f32: #[should_panic],
1279+
f64: #[should_panic],
1280+
f128: #[should_panic, cfg(any(miri, target_has_reliable_f128))],
1281+
},
1282+
test<Float> {
1283+
let _ = Float::ONE.clamp_to(Float::NAN..=1.0);
1284+
}
1285+
}
1286+
1287+
float_test! {
1288+
name: clamp_to_max_is_nan,
1289+
attrs: {
1290+
const: #[cfg(false)],
1291+
f16: #[should_panic, cfg(any(miri, target_has_reliable_f16))],
1292+
f32: #[should_panic],
1293+
f64: #[should_panic],
1294+
f128: #[should_panic, cfg(any(miri, target_has_reliable_f128))],
1295+
},
1296+
test<Float> {
1297+
let _ = Float::ONE.clamp_to(3.0..=Float::NAN);
1298+
}
1299+
}
1300+
12591301
float_test! {
12601302
name: total_cmp,
12611303
attrs: {

0 commit comments

Comments
 (0)