Skip to content

Commit

Permalink
Add missing test coverage for the previous commit's changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahcodedthat committed Feb 11, 2024
1 parent 05c62cd commit 4819eaf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/datetime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,13 @@ fn test_from_system_time() {
)
.unwrap()
);
assert_eq!(
DateTime::<Utc>::try_from(UNIX_EPOCH - Duration::new(999_999_999, 0)).unwrap(),
Utc.from_local_datetime(
&NaiveDate::from_ymd_opt(1938, 4, 24).unwrap().and_hms_nano_opt(22, 13, 21, 0).unwrap()
)
.unwrap()
);

// DateTime<Utc> -> SystemTime
assert_eq!(SystemTime::try_from(epoch).unwrap(), UNIX_EPOCH);
Expand Down Expand Up @@ -1204,7 +1211,10 @@ fn test_from_system_time() {
// DateTime<any tz> -> SystemTime (via `with_timezone`)
#[cfg(feature = "clock")]
{
assert_eq!(SystemTime::try_from(epoch.with_timezone(&Local)).unwrap(), UNIX_EPOCH);
let local_at_epoch = epoch.with_timezone(&Local);
let local_systemtime_at_epoch = SystemTime::try_from(local_at_epoch).unwrap();
assert_eq!(local_systemtime_at_epoch, UNIX_EPOCH);
assert_eq!(DateTime::<Local>::try_from(local_systemtime_at_epoch).unwrap(), local_at_epoch);
}
assert_eq!(
SystemTime::try_from(epoch.with_timezone(&FixedOffset::east(32400).unwrap())).unwrap(),
Expand Down

0 comments on commit 4819eaf

Please sign in to comment.