Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/datetime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1901,3 +1901,47 @@
assert_eq!(nanos, nanos2);
}
}

#[cfg(feature = "alloc")]
#[test]
fn try_to_rfc2822() {
let ndt = NaiveDateTime::new(
NaiveDate::from_ymd_opt(9999, 12, 31).unwrap(),
NaiveTime::from_hms_nano_opt(
60,
60,
60,
999999999,
)
.or(NaiveTime::from_hms_opt(
60,
60,
60,
))
.unwrap_or_default(),
).and_utc();
let res = ndt.to_rfc2822();
assert_eq!(res, "Fri, 31 Dec 9999 00:00:00 +0000");
}


#[cfg(feature = "alloc")]
#[should_panic]
#[test]
fn try_to_rfc2822_panics_year_greater_than_9999() {
assert!(NaiveDateTime::new(
NaiveDate::from_ymd_opt(10000, 12, 31).unwrap(),
NaiveTime::from_hms_nano_opt(
60,
60,
60,
999999999,
)
.or(NaiveTime::from_hms_opt(
60,
60,
60,
))
.unwrap_or_default(),
).and_utc().to_rfc2822() == "")
}

Check warning on line 1947 in src/datetime/tests.rs

View check run for this annotation

Codecov / codecov/patch

src/datetime/tests.rs#L1947

Added line #L1947 was not covered by tests
Loading