Skip to content

Commit c907535

Browse files
committed
test(library): add feature in lib file; fix overflow test; add assert_eq for FROM_NANOS_U128
1 parent 27d11bc commit c907535

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

library/coretests/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#![feature(duration_constants)]
3838
#![feature(duration_constructors)]
3939
#![feature(duration_constructors_lite)]
40+
#![feature(duration_from_nanos_u128)]
4041
#![feature(error_generic_member_access)]
4142
#![feature(exact_div)]
4243
#![feature(exact_size_is_empty)]

library/coretests/tests/time.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn from_weeks_overflow() {
4848
#[test]
4949
#[should_panic]
5050
fn from_nanos_u128_overflow() {
51-
let overflow = (u64::MAX * NANOS_PER_SEC) + (NANOS_PER_SEC - 1) + 1;
51+
let overflow = (u64::MAX as u128 * 1_000_000_000) + (1_000_000_000 - 1) + 1;
5252
let _ = Duration::from_nanos_u128(overflow);
5353
}
5454

@@ -535,6 +535,9 @@ fn duration_const() {
535535
const FROM_NANOS: Duration = Duration::from_nanos(1_000_000_000);
536536
assert_eq!(FROM_NANOS, Duration::SECOND);
537537

538+
const FROM_NANOS_U128: Duration = Duration::from_nanos_u128(NANOS);
539+
assert_eq!(FROM_NANOS_U128, Duration::SECOND);
540+
538541
const MAX: Duration = Duration::new(u64::MAX, 999_999_999);
539542

540543
const CHECKED_ADD: Option<Duration> = MAX.checked_add(Duration::SECOND);

0 commit comments

Comments
 (0)