diff --git a/tests/offset_date_time.rs b/tests/offset_date_time.rs index ffccf8044..29b2eb4fd 100644 --- a/tests/offset_date_time.rs +++ b/tests/offset_date_time.rs @@ -3,7 +3,7 @@ use std::time::{Duration as StdDuration, SystemTime}; use time::ext::{NumericalDuration, NumericalStdDuration}; use time::macros::{date, datetime, offset, time}; -use time::{Date, Duration, Month, OffsetDateTime, PrimitiveDateTime, Result, Weekday}; +use time::{Date, Duration, Month, OffsetDateTime, PrimitiveDateTime, Weekday}; #[test] fn new_utc() { @@ -445,7 +445,7 @@ fn replace_offset() { } #[test] -fn replace_year() -> Result<()> { +fn replace_year() { assert_eq!( datetime!(2022 - 02 - 18 12:00 +01).replace_year(2019), Ok(datetime!(2019 - 02 - 18 12:00 +01)) @@ -460,11 +460,10 @@ fn replace_year() -> Result<()> { .replace_year(1_000_000_000) .is_err() ); // 1_000_000_000 isn't a valid year - Ok(()) } #[test] -fn replace_month() -> Result<()> { +fn replace_month() { assert_eq!( datetime!(2022 - 02 - 18 12:00 +01).replace_month(Month::January), Ok(datetime!(2022 - 01 - 18 12:00 +01)) @@ -474,18 +473,16 @@ fn replace_month() -> Result<()> { .replace_month(Month::February) .is_err() ); // 30 isn't a valid day in February - Ok(()) } #[test] -fn replace_day() -> Result<()> { +fn replace_day() { assert_eq!( datetime!(2022 - 02 - 18 12:00 +01).replace_day(1), Ok(datetime!(2022 - 02 - 01 12:00 +01)) ); assert!(datetime!(2022 - 02 - 18 12:00 +01).replace_day(0).is_err()); // 00 isn't a valid day assert!(datetime!(2022 - 02 - 18 12:00 +01).replace_day(30).is_err()); // 30 isn't a valid day in February - Ok(()) } #[test] @@ -512,7 +509,7 @@ fn replace_ordinal() { } #[test] -fn replace_hour() -> Result<()> { +fn replace_hour() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006 +01).replace_hour(7), Ok(datetime!(2022 - 02 - 18 07:02:03.004_005_006 +01)) @@ -522,11 +519,10 @@ fn replace_hour() -> Result<()> { .replace_hour(24) .is_err() ); // 24 isn't a valid hour - Ok(()) } #[test] -fn replace_minute() -> Result<()> { +fn replace_minute() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006 +01).replace_minute(7), Ok(datetime!(2022 - 02 - 18 01:07:03.004_005_006 +01)) @@ -536,11 +532,10 @@ fn replace_minute() -> Result<()> { .replace_minute(60) .is_err() ); // 60 isn't a valid minute - Ok(()) } #[test] -fn replace_second() -> Result<()> { +fn replace_second() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006 +01).replace_second(7), Ok(datetime!(2022 - 02 - 18 01:02:07.004_005_006 +01)) @@ -550,11 +545,10 @@ fn replace_second() -> Result<()> { .replace_second(60) .is_err() ); // 60 isn't a valid second - Ok(()) } #[test] -fn replace_millisecond() -> Result<()> { +fn replace_millisecond() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006 +01).replace_millisecond(7), Ok(datetime!(2022 - 02 - 18 01:02:03.007 +01)) @@ -564,11 +558,10 @@ fn replace_millisecond() -> Result<()> { .replace_millisecond(1_000) .is_err() ); // 1_000 isn't a valid millisecond - Ok(()) } #[test] -fn replace_microsecond() -> Result<()> { +fn replace_microsecond() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006 +01).replace_microsecond(7_008), Ok(datetime!(2022 - 02 - 18 01:02:03.007_008 +01)) @@ -578,11 +571,10 @@ fn replace_microsecond() -> Result<()> { .replace_microsecond(1_000_000) .is_err() ); // 1_000_000 isn't a valid microsecond - Ok(()) } #[test] -fn replace_nanosecond() -> Result<()> { +fn replace_nanosecond() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006 +01).replace_nanosecond(7_008_009), Ok(datetime!(2022 - 02 - 18 01:02:03.007_008_009 +01)) @@ -592,7 +584,6 @@ fn replace_nanosecond() -> Result<()> { .replace_nanosecond(1_000_000_000) .is_err() ); // 1_000_000_000 isn't a valid nanosecond - Ok(()) } #[test] diff --git a/tests/primitive_date_time.rs b/tests/primitive_date_time.rs index 7e7709a5b..80b6da9e8 100644 --- a/tests/primitive_date_time.rs +++ b/tests/primitive_date_time.rs @@ -2,7 +2,7 @@ use std::cmp::Ordering; use time::ext::{NumericalDuration, NumericalStdDuration}; use time::macros::{date, datetime, offset, time}; -use time::{Duration, Month, PrimitiveDateTime, Result, Weekday}; +use time::{Duration, Month, PrimitiveDateTime, Weekday}; #[test] fn new() { @@ -248,7 +248,7 @@ fn replace_date() { } #[test] -fn replace_year() -> Result<()> { +fn replace_year() { assert_eq!( datetime!(2022 - 02 - 18 12:00).replace_year(2019), Ok(datetime!(2019 - 02 - 18 12:00)) @@ -263,11 +263,10 @@ fn replace_year() -> Result<()> { .replace_year(1_000_000_000) .is_err() ); // 1_000_000_000 isn't a valid year - Ok(()) } #[test] -fn replace_month() -> Result<()> { +fn replace_month() { assert_eq!( datetime!(2022 - 02 - 18 12:00).replace_month(Month::January), Ok(datetime!(2022 - 01 - 18 12:00)) @@ -277,18 +276,16 @@ fn replace_month() -> Result<()> { .replace_month(Month::February) .is_err() ); // 30 isn't a valid day in February - Ok(()) } #[test] -fn replace_day() -> Result<()> { +fn replace_day() { assert_eq!( datetime!(2022 - 02 - 18 12:00).replace_day(1), Ok(datetime!(2022 - 02 - 01 12:00)) ); assert!(datetime!(2022 - 02 - 18 12:00).replace_day(0).is_err()); // 00 isn't a valid day assert!(datetime!(2022 - 02 - 18 12:00).replace_day(30).is_err()); // 30 isn't a valid day in February - Ok(()) } #[test] @@ -307,7 +304,7 @@ fn replace_ordinal() { } #[test] -fn replace_hour() -> Result<()> { +fn replace_hour() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006).replace_hour(7), Ok(datetime!(2022 - 02 - 18 07:02:03.004_005_006)) @@ -317,11 +314,10 @@ fn replace_hour() -> Result<()> { .replace_hour(24) .is_err() ); // 24 isn't a valid hour - Ok(()) } #[test] -fn replace_minute() -> Result<()> { +fn replace_minute() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006).replace_minute(7), Ok(datetime!(2022 - 02 - 18 01:07:03.004_005_006)) @@ -331,11 +327,10 @@ fn replace_minute() -> Result<()> { .replace_minute(60) .is_err() ); // 60 isn't a valid minute - Ok(()) } #[test] -fn replace_second() -> Result<()> { +fn replace_second() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006).replace_second(7), Ok(datetime!(2022 - 02 - 18 01:02:07.004_005_006)) @@ -345,11 +340,10 @@ fn replace_second() -> Result<()> { .replace_second(60) .is_err() ); // 60 isn't a valid second - Ok(()) } #[test] -fn replace_millisecond() -> Result<()> { +fn replace_millisecond() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006).replace_millisecond(7), Ok(datetime!(2022 - 02 - 18 01:02:03.007)) @@ -359,11 +353,10 @@ fn replace_millisecond() -> Result<()> { .replace_millisecond(1_000) .is_err() ); // 1_000 isn't a valid millisecond - Ok(()) } #[test] -fn replace_microsecond() -> Result<()> { +fn replace_microsecond() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006).replace_microsecond(7_008), Ok(datetime!(2022 - 02 - 18 01:02:03.007_008)) @@ -373,11 +366,10 @@ fn replace_microsecond() -> Result<()> { .replace_microsecond(1_000_000) .is_err() ); // 1_000_000 isn't a valid microsecond - Ok(()) } #[test] -fn replace_nanosecond() -> Result<()> { +fn replace_nanosecond() { assert_eq!( datetime!(2022 - 02 - 18 01:02:03.004_005_006).replace_nanosecond(7_008_009), Ok(datetime!(2022 - 02 - 18 01:02:03.007_008_009)) @@ -387,7 +379,6 @@ fn replace_nanosecond() -> Result<()> { .replace_nanosecond(1_000_000_000) .is_err() ); // 1_000_000_000 isn't a valid nanosecond - Ok(()) } #[test] diff --git a/tests/time.rs b/tests/time.rs index 5f3f88b68..764852996 100644 --- a/tests/time.rs +++ b/tests/time.rs @@ -147,47 +147,43 @@ fn nanosecond() -> Result<()> { } #[test] -fn replace_hour() -> Result<()> { +fn replace_hour() { assert_eq!( - time!(1:02:03.004_005_006).replace_hour(7)?, - time!(7:02:03.004_005_006) + time!(1:02:03.004_005_006).replace_hour(7), + Ok(time!(7:02:03.004_005_006)) ); assert!(time!(1:02:03.004_005_006).replace_hour(24).is_err()); - Ok(()) } #[test] -fn replace_minute() -> Result<()> { +fn replace_minute() { assert_eq!( - time!(1:02:03.004_005_006).replace_minute(7)?, - time!(1:07:03.004_005_006) + time!(1:02:03.004_005_006).replace_minute(7), + Ok(time!(1:07:03.004_005_006)) ); assert!(time!(1:02:03.004_005_006).replace_minute(60).is_err()); - Ok(()) } #[test] -fn replace_second() -> Result<()> { +fn replace_second() { assert_eq!( - time!(1:02:03.004_005_006).replace_second(7)?, - time!(1:02:07.004_005_006) + time!(1:02:03.004_005_006).replace_second(7), + Ok(time!(1:02:07.004_005_006)) ); assert!(time!(1:02:03.004_005_006).replace_second(60).is_err()); - Ok(()) } #[test] -fn replace_millisecond() -> Result<()> { +fn replace_millisecond() { assert_eq!( - time!(1:02:03.004_005_006).replace_millisecond(7)?, - time!(1:02:03.007) + time!(1:02:03.004_005_006).replace_millisecond(7), + Ok(time!(1:02:03.007)) ); assert!( time!(1:02:03.004_005_006) .replace_millisecond(1_000) .is_err() ); - Ok(()) } #[test] @@ -198,31 +194,29 @@ fn replace_millisecond_regression() { } #[test] -fn replace_microsecond() -> Result<()> { +fn replace_microsecond() { assert_eq!( - time!(1:02:03.004_005_006).replace_microsecond(7_008)?, - time!(1:02:03.007_008) + time!(1:02:03.004_005_006).replace_microsecond(7_008), + Ok(time!(1:02:03.007_008)) ); assert!( time!(1:02:03.004_005_006) .replace_microsecond(1_000_000) .is_err() ); - Ok(()) } #[test] -fn replace_nanosecond() -> Result<()> { +fn replace_nanosecond() { assert_eq!( - time!(1:02:03.004_005_006).replace_nanosecond(7_008_009)?, - time!(1:02:03.007_008_009) + time!(1:02:03.004_005_006).replace_nanosecond(7_008_009), + Ok(time!(1:02:03.007_008_009)) ); assert!( time!(1:02:03.004_005_006) .replace_nanosecond(1_000_000_000) .is_err() ); - Ok(()) } #[test]