mirror of
https://github.com/chronotope/chrono.git
synced 2025-10-03 07:46:24 +00:00
Move test in format::parse
to test
module
This commit is contained in:
parent
67c59fd08e
commit
b2cb0fdf7b
@ -551,11 +551,12 @@ impl str::FromStr for DateTime<FixedOffset> {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn test_parse() {
|
||||
use super::IMPOSSIBLE;
|
||||
use super::*;
|
||||
mod tests {
|
||||
use crate::format::*;
|
||||
use crate::{DateTime, FixedOffset, TimeZone, Utc};
|
||||
|
||||
#[test]
|
||||
fn test_parse() {
|
||||
// workaround for Rust issue #22255
|
||||
fn parse_all(s: &str, items: &[Item]) -> ParseResult<Parsed> {
|
||||
let mut parsed = Parsed::new();
|
||||
@ -1233,16 +1234,10 @@ fn test_parse() {
|
||||
check!("12345678901234.56789",
|
||||
[num!(Timestamp), fix!(Nanosecond)];
|
||||
nanosecond: 567_890_000, timestamp: 12_345_678_901_234);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn test_rfc2822() {
|
||||
use super::NOT_ENOUGH;
|
||||
use super::*;
|
||||
use crate::offset::FixedOffset;
|
||||
use crate::DateTime;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rfc2822() {
|
||||
// Test data - (input, Ok(expected result after parse and format) or Err(error code))
|
||||
let testdates = [
|
||||
("Tue, 20 Jan 2015 17:35:20 -0800", Ok("Tue, 20 Jan 2015 17:35:20 -0800")), // normal case
|
||||
@ -1335,13 +1330,10 @@ fn test_rfc2822() {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn parse_rfc850() {
|
||||
use crate::{TimeZone, Utc};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_rfc850() {
|
||||
static RFC850_FMT: &str = "%A, %d-%b-%y %T GMT";
|
||||
|
||||
let dt_str = "Sunday, 06-Nov-94 08:49:37 GMT";
|
||||
@ -1356,8 +1348,14 @@ fn parse_rfc850() {
|
||||
// Check that the rest of the weekdays parse correctly (this test originally failed because
|
||||
// Sunday parsed incorrectly).
|
||||
let testdates = [
|
||||
(Utc.with_ymd_and_hms(1994, 11, 7, 8, 49, 37).unwrap(), "Monday, 07-Nov-94 08:49:37 GMT"),
|
||||
(Utc.with_ymd_and_hms(1994, 11, 8, 8, 49, 37).unwrap(), "Tuesday, 08-Nov-94 08:49:37 GMT"),
|
||||
(
|
||||
Utc.with_ymd_and_hms(1994, 11, 7, 8, 49, 37).unwrap(),
|
||||
"Monday, 07-Nov-94 08:49:37 GMT",
|
||||
),
|
||||
(
|
||||
Utc.with_ymd_and_hms(1994, 11, 8, 8, 49, 37).unwrap(),
|
||||
"Tuesday, 08-Nov-94 08:49:37 GMT",
|
||||
),
|
||||
(
|
||||
Utc.with_ymd_and_hms(1994, 11, 9, 8, 49, 37).unwrap(),
|
||||
"Wednesday, 09-Nov-94 08:49:37 GMT",
|
||||
@ -1366,7 +1364,10 @@ fn parse_rfc850() {
|
||||
Utc.with_ymd_and_hms(1994, 11, 10, 8, 49, 37).unwrap(),
|
||||
"Thursday, 10-Nov-94 08:49:37 GMT",
|
||||
),
|
||||
(Utc.with_ymd_and_hms(1994, 11, 11, 8, 49, 37).unwrap(), "Friday, 11-Nov-94 08:49:37 GMT"),
|
||||
(
|
||||
Utc.with_ymd_and_hms(1994, 11, 11, 8, 49, 37).unwrap(),
|
||||
"Friday, 11-Nov-94 08:49:37 GMT",
|
||||
),
|
||||
(
|
||||
Utc.with_ymd_and_hms(1994, 11, 12, 8, 49, 37).unwrap(),
|
||||
"Saturday, 12-Nov-94 08:49:37 GMT",
|
||||
@ -1395,11 +1396,11 @@ fn parse_rfc850() {
|
||||
for val in &test_dates_fail {
|
||||
assert!(Utc.datetime_from_str(val, RFC850_FMT).is_err());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn test_rfc3339() {
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn test_rfc3339() {
|
||||
use super::*;
|
||||
use crate::offset::FixedOffset;
|
||||
use crate::DateTime;
|
||||
@ -1485,12 +1486,12 @@ fn test_rfc3339() {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn test_issue_1010() {
|
||||
#[test]
|
||||
fn test_issue_1010() {
|
||||
let dt = crate::NaiveDateTime::parse_from_str("\u{c}SUN\u{e}\u{3000}\0m@J\u{3000}\0\u{3000}\0m\u{c}!\u{c}\u{b}\u{c}\u{c}\u{c}\u{c}%A\u{c}\u{b}\0SU\u{c}\u{c}",
|
||||
"\u{c}\u{c}%A\u{c}\u{b}\0SUN\u{c}\u{c}\u{c}SUNN\u{c}\u{c}\u{c}SUN\u{c}\u{c}!\u{c}\u{b}\u{c}\u{c}\u{c}\u{c}%A\u{c}\u{b}%a");
|
||||
assert_eq!(dt, Err(ParseError(ParseErrorKind::Invalid)));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user