Skip to content

Commit

Permalink
test that checked functions do not cause panic
Browse files Browse the repository at this point in the history
  • Loading branch information
bragov4ik committed Jul 22, 2024
1 parent 5e67221 commit 4c56937
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/naive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,18 @@ mod test {
let date_min = NaiveDate::MIN;
assert!(date_min.week(Weekday::Mon).last_day() >= date_min);
}

#[test]
fn test_naiveweek_checked_no_panic() {
let date_max = NaiveDate::MAX;
if let Some(last) = date_max.week(Weekday::Mon).checked_last_day() {
assert!(last == date_max);
}
let date_min = NaiveDate::MIN;
if let Some(first) = date_min.week(Weekday::Mon).checked_first_day() {
assert!(first == date_min);
}
let _ = date_min.week(Weekday::Mon).checked_days();
let _ = date_max.week(Weekday::Mon).checked_days();
}
}

0 comments on commit 4c56937

Please sign in to comment.