Skip to content

Commit

Permalink
Tests: replace TimeDelta::weeks with try_weeks
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Mar 6, 2024
1 parent 51a1aa2 commit e8f9b5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ mod tests {
"2020-10-28 00:00:00 +01:00"
);
assert_eq!(
dt.duration_round(TimeDelta::weeks(1)).unwrap().to_string(),
dt.duration_round(TimeDelta::try_weeks(1).unwrap()).unwrap().to_string(),
"2020-10-29 00:00:00 +01:00"
);

Expand All @@ -529,7 +529,7 @@ mod tests {
"2020-10-28 00:00:00 -01:00"
);
assert_eq!(
dt.duration_round(TimeDelta::weeks(1)).unwrap().to_string(),
dt.duration_round(TimeDelta::try_weeks(1).unwrap()).unwrap().to_string(),
"2020-10-29 00:00:00 -01:00"
);
}
Expand Down Expand Up @@ -679,7 +679,7 @@ mod tests {
"2020-10-27 00:00:00 +01:00"
);
assert_eq!(
dt.duration_trunc(TimeDelta::weeks(1)).unwrap().to_string(),
dt.duration_trunc(TimeDelta::try_weeks(1).unwrap()).unwrap().to_string(),
"2020-10-22 00:00:00 +01:00"
);

Expand All @@ -691,7 +691,7 @@ mod tests {
"2020-10-27 00:00:00 -01:00"
);
assert_eq!(
dt.duration_trunc(TimeDelta::weeks(1)).unwrap().to_string(),
dt.duration_trunc(TimeDelta::try_weeks(1).unwrap()).unwrap().to_string(),
"2020-10-22 00:00:00 -01:00"
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/time_delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ impl arbitrary::Arbitrary<'_> for TimeDelta {
mod tests {
use super::OutOfRangeError;
use super::{TimeDelta, MAX, MIN};
use crate::expect;
use core::time::Duration;

#[test]
Expand Down Expand Up @@ -1188,7 +1189,7 @@ mod tests {

#[test]
fn test_duration_const() {
const ONE_WEEK: TimeDelta = TimeDelta::weeks(1);
const ONE_WEEK: TimeDelta = expect!(TimeDelta::try_weeks(1), "");
const ONE_DAY: TimeDelta = TimeDelta::days(1);
const ONE_HOUR: TimeDelta = TimeDelta::hours(1);
const ONE_MINUTE: TimeDelta = TimeDelta::minutes(1);
Expand Down

0 comments on commit e8f9b5e

Please sign in to comment.