Skip to content

Commit

Permalink
Parse to NaiveDateTime in parse_rfc850 test
Browse files Browse the repository at this point in the history
The format string doesn't contain any offset info.
  • Loading branch information
pitdicker committed Sep 5, 2023
1 parent d56049f commit 935e7b5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/format/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)] {
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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 = [
Expand All @@ -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());
}
}

Expand Down

0 comments on commit 935e7b5

Please sign in to comment.