Fix Duration::{try_,}from_secs_f{32,64}(-0.0)
This commit is contained in:
parent
9b0a099dfc
commit
c9948f5c5f
@ -1279,7 +1279,7 @@ macro_rules! try_from_secs {
|
||||
const MANT_MASK: $bits_ty = (1 << $mant_bits) - 1;
|
||||
const EXP_MASK: $bits_ty = (1 << $exp_bits) - 1;
|
||||
|
||||
if $secs.is_sign_negative() {
|
||||
if $secs < 0.0 {
|
||||
return Err(FromFloatSecsError { kind: FromFloatSecsErrorKind::Negative });
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,7 @@
|
||||
#![feature(provide_any)]
|
||||
#![feature(utf8_chunks)]
|
||||
#![feature(is_ascii_octdigit)]
|
||||
#![feature(duration_checked_float)]
|
||||
#![deny(unsafe_op_in_unsafe_fn)]
|
||||
|
||||
extern crate test;
|
||||
|
@ -467,3 +467,11 @@ fn duration_const() {
|
||||
const SATURATING_MUL: Duration = MAX.saturating_mul(2);
|
||||
assert_eq!(SATURATING_MUL, MAX);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_neg_zero() {
|
||||
assert_eq!(Duration::try_from_secs_f32(-0.0), Ok(Duration::ZERO));
|
||||
assert_eq!(Duration::try_from_secs_f64(-0.0), Ok(Duration::ZERO));
|
||||
assert_eq!(Duration::from_secs_f32(-0.0), Duration::ZERO);
|
||||
assert_eq!(Duration::from_secs_f64(-0.0), Duration::ZERO);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user