Skip to content

Commit

Permalink
Test that NaiveWeek checked functions don't panic
Browse files Browse the repository at this point in the history
  • Loading branch information
bragov4ik authored and djc committed Aug 19, 2024
1 parent f765936 commit 081c648
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 @@ -264,4 +264,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 081c648

Please sign in to comment.