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 @@ -360,6 +360,28 @@ mod tests {
360360 assert ! ( Instant :: try_new( min_minus_one) . is_err( ) ) ;
361361 }
362362
363+ #[ test]
364+ fn max_min_epoch_millseconds ( ) {
365+ // Assert the casting is valid.
366+ let max = NS_MAX_INSTANT ;
367+ let min = NS_MIN_INSTANT ;
368+ let max_instant = Instant :: try_new ( max) . unwrap ( ) ;
369+ let min_instant = Instant :: try_new ( min) . unwrap ( ) ;
370+
371+ // Assert max and min are valid for casting.
372+ assert_eq ! (
373+ max_instant. epoch_milliseconds( ) ,
374+ max. div_euclid( 1_000_000 ) as i64
375+ ) ;
376+ assert_eq ! (
377+ min_instant. epoch_milliseconds( ) ,
378+ min. div_euclid( 1_000_000 ) as i64
379+ ) ;
380+ // Assert the max and min are not being truncated.
381+ assert_ne ! ( max_instant. epoch_milliseconds( ) , i64 :: MAX ) ;
382+ assert_ne ! ( max_instant. epoch_milliseconds( ) , i64 :: MIN ) ;
383+ }
384+
363385 #[ test]
364386 fn instant_parsing_limits ( ) {
365387 // valid cases
You can’t perform that action at this time.
0 commit comments