diff options
Diffstat (limited to 'components/hyper_serde/tests')
-rw-r--r-- | components/hyper_serde/tests/supported.rs | 5 | ||||
-rw-r--r-- | components/hyper_serde/tests/tokens.rs | 17 |
2 files changed, 9 insertions, 13 deletions
diff --git a/components/hyper_serde/tests/supported.rs b/components/hyper_serde/tests/supported.rs index 4eddd69adef..54480903c7e 100644 --- a/components/hyper_serde/tests/supported.rs +++ b/components/hyper_serde/tests/supported.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::time::SystemTime; - use cookie::Cookie; use headers::ContentType; use http::header::HeaderMap; @@ -17,6 +15,7 @@ use hyper::{Method, StatusCode, Uri}; use hyper_serde::{De, Ser, Serde}; use mime::Mime; use serde::{Deserialize, Serialize}; +use time::Tm; fn is_supported<T>() where @@ -34,6 +33,6 @@ fn supported() { is_supported::<Method>(); is_supported::<Mime>(); is_supported::<StatusCode>(); - is_supported::<SystemTime>(); + is_supported::<Tm>(); is_supported::<Uri>(); } diff --git a/components/hyper_serde/tests/tokens.rs b/components/hyper_serde/tests/tokens.rs index 2ba79ce3bb6..d7ad09f4e9c 100644 --- a/components/hyper_serde/tests/tokens.rs +++ b/components/hyper_serde/tests/tokens.rs @@ -15,6 +15,7 @@ use http::StatusCode; use hyper::{Method, Uri}; use hyper_serde::{De, Ser}; use serde_test::{assert_de_tokens, assert_ser_tokens, Token}; +use time::Duration; #[test] fn test_content_type() { @@ -31,7 +32,7 @@ fn test_cookie() { // string with a bunch of indices in it which apparently is different from the exact same // cookie but parsed as a bunch of strings. let cookie: Cookie = Cookie::build("Hello", "World!") - .max_age(time::Duration::seconds(42)) + .max_age(Duration::seconds(42)) .domain("servo.org") .path("/") .secure(true) @@ -111,18 +112,14 @@ fn test_raw_status() { } #[test] -fn test_system_time_serialization() { - use std::time::SystemTime; +fn test_tm() { + use time::strptime; - use chrono::{NaiveDateTime, TimeZone, Utc}; + let time = strptime("2017-02-22T12:03:31Z", "%Y-%m-%dT%H:%M:%SZ").unwrap(); + let tokens = &[Token::Str("2017-02-22T12:03:31Z")]; - let time = SystemTime::from(Utc.from_utc_datetime( - &NaiveDateTime::parse_from_str("2023-01-15T12:53:31Z", "%Y-%m-%dT%H:%M:%SZ").unwrap(), - )); - let tokens = &[Token::Str("2023-01-15T12:53:31Z")]; - - assert_de_tokens(&De::new(time), tokens); assert_ser_tokens(&Ser::new(&time), tokens); + assert_de_tokens(&De::new(time), tokens); } #[test] |