Parse to NaiveDateTime in parse_rfc850 test

The format string doesn't contain any offset info.
This commit is contained in:
Paul Dicker 2023-09-03 13:46:56 +02:00 committed by Paul Dicker
parent d56049f52a
commit 935e7b5953

View File

@ -598,7 +598,7 @@ fn parse_rfc3339_relaxed<'a>(parsed: &mut Parsed, mut s: &'a str) -> ParseResult
#[cfg(test)]
mod tests {
use crate::format::*;
use crate::{DateTime, FixedOffset, TimeZone, Timelike, Utc};
use crate::{DateTime, FixedOffset, NaiveDateTime, TimeZone, Timelike, Utc};
macro_rules! parsed {
($($k:ident: $v:expr),*) => (#[allow(unused_mut)] {
@ -1704,7 +1704,10 @@ mod tests {
assert_eq!(dt.format(RFC850_FMT).to_string(), "Sunday, 06-Nov-94 08:49:37 GMT");
// Check that it parses correctly
assert_eq!(Ok(dt), Utc.datetime_from_str("Sunday, 06-Nov-94 08:49:37 GMT", RFC850_FMT));
assert_eq!(
NaiveDateTime::parse_from_str("Sunday, 06-Nov-94 08:49:37 GMT", RFC850_FMT),
Ok(dt.naive_utc())
);
// Check that the rest of the weekdays parse correctly (this test originally failed because
// Sunday parsed incorrectly).
@ -1736,7 +1739,7 @@ mod tests {
];
for val in &testdates {
assert_eq!(Ok(val.0), Utc.datetime_from_str(val.1, RFC850_FMT));
assert_eq!(NaiveDateTime::parse_from_str(val.1, RFC850_FMT), Ok(val.0.naive_utc()));
}
let test_dates_fail = [
@ -1755,7 +1758,7 @@ mod tests {
];
for val in &test_dates_fail {
assert!(Utc.datetime_from_str(val, RFC850_FMT).is_err());
assert!(NaiveDateTime::parse_from_str(val, RFC850_FMT).is_err());
}
}