File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -350,6 +350,28 @@ mod tests {
350350 assert ! ( Instant :: try_new( min_minus_one) . is_err( ) ) ;
351351 }
352352
353+ #[ test]
354+ fn max_min_epoch_millseconds ( ) {
355+ // Assert the casting is valid.
356+ let max = NS_MAX_INSTANT ;
357+ let min = NS_MIN_INSTANT ;
358+ let max_instant = Instant :: try_new ( max) . unwrap ( ) ;
359+ let min_instant = Instant :: try_new ( min) . unwrap ( ) ;
360+
361+ // Assert max and min are valid for casting.
362+ assert_eq ! (
363+ max_instant. epoch_milliseconds( ) ,
364+ max. div_euclid( 1_000_000 ) as i64
365+ ) ;
366+ assert_eq ! (
367+ min_instant. epoch_milliseconds( ) ,
368+ min. div_euclid( 1_000_000 ) as i64
369+ ) ;
370+ // Assert the max and min are not being truncated.
371+ assert_ne ! ( max_instant. epoch_milliseconds( ) , i64 :: MAX ) ;
372+ assert_ne ! ( max_instant. epoch_milliseconds( ) , i64 :: MIN ) ;
373+ }
374+
353375 #[ test]
354376 fn instant_parsing_limits ( ) {
355377 // valid cases
You can’t perform that action at this time.
0 commit comments