diff --git a/src/naive/datetime/tests.rs b/src/naive/datetime/tests.rs index 3df475b9c1..806268d817 100644 --- a/src/naive/datetime/tests.rs +++ b/src/naive/datetime/tests.rs @@ -29,6 +29,16 @@ fn test_datetime_from_timestamp_millis() { let naive_datetime = NaiveDateTime::from_timestamp_millis(timestamp_millis); assert!(naive_datetime.is_none()); } + + // Test that the result of `from_timestamp_millis` compares equal to + // that of `from_timestamp_opt`. + let secs_test = [0, 1, 2, 1000, 1234, 12345678, -1, -2, -1000, -12345678]; + for secs in secs_test.iter().cloned() { + assert_eq!( + NaiveDateTime::from_timestamp_millis(secs * 1000), + NaiveDateTime::from_timestamp_opt(secs, 0) + ); + } } #[test]