use revue::widget::data::calendar::{days_in_month, first_day_of_month, is_leap_year};
#[test]
fn test_days_in_month_january() {
assert_eq!(days_in_month(2024, 1), 31);
}
#[test]
fn test_days_in_month_february_non_leap() {
assert_eq!(days_in_month(2023, 2), 28);
}
#[test]
fn test_days_in_month_february_leap() {
assert_eq!(days_in_month(2024, 2), 29);
}
#[test]
fn test_days_in_month_april() {
assert_eq!(days_in_month(2024, 4), 30);
}
#[test]
fn test_days_in_month_december() {
assert_eq!(days_in_month(2024, 12), 31);
}
#[test]
fn test_days_in_month_invalid() {
assert_eq!(days_in_month(2024, 13), 0);
}
#[test]
fn test_days_in_month_century_leap_year() {
assert_eq!(days_in_month(2000, 2), 29);
}
#[test]
fn test_days_in_month_century_non_leap() {
assert_eq!(days_in_month(1900, 2), 28);
}
#[test]
fn test_is_leap_year_common() {
assert!(!is_leap_year(2023));
}
#[test]
fn test_is_leap_year_divisible_by_4() {
assert!(is_leap_year(2024));
}
#[test]
fn test_is_leap_year_century() {
assert!(!is_leap_year(1900));
}
#[test]
fn test_is_leap_year_century_divisible_by_400() {
assert!(is_leap_year(2000));
}
#[test]
fn test_is_leap_year_negative() {
let result = is_leap_year(0);
assert!(result);
}
#[test]
fn test_first_day_of_month_january_2024() {
let day = first_day_of_month(2024, 1);
assert_eq!(day, 1);
}
#[test]
fn test_first_day_of_month_february_2024() {
let day = first_day_of_month(2024, 2);
assert_eq!(day, 4);
}
#[test]
fn test_first_day_of_month_march_2024() {
let day = first_day_of_month(2024, 3);
assert_eq!(day, 5);
}
#[test]
fn test_first_day_of_month_january_2023() {
let day = first_day_of_month(2023, 1);
assert_eq!(day, 0);
}
#[test]
fn test_first_day_of_month_february_2023() {
let day = first_day_of_month(2023, 2);
assert_eq!(day, 3);
}
#[test]
fn test_first_day_of_month_range() {
for year in 1900..=2100 {
for month in 1..=12 {
let day = first_day_of_month(year, month);
assert!(day < 7);
}
}
}
#[test]
fn test_first_day_of_month_march_leap_year() {
let day = first_day_of_month(2000, 3);
assert_eq!(day, 3);
}
#[test]
fn test_first_day_of_month_february_non_leap() {
let day = first_day_of_month(2023, 2);
assert_eq!(day, 3);
}