Finish leap year

This commit is contained in:
Blizzard Finnegan 2023-08-22 11:00:13 -04:00
parent 56252ddfd3
commit 8ec359efef
Signed by: blizzardfinnegan
GPG key ID: 61C1E13067E0018E
2 changed files with 1 additions and 14 deletions

View file

@ -1,3 +1,3 @@
pub fn is_leap_year(year: u64) -> bool {
unimplemented!("true if {} is a leap year", year)
(year % 4 == 0 && year % 100 != 0) || year % 400 == 0
}

View file

@ -8,61 +8,51 @@ fn test_year_not_divisible_by_4_common_year() {
}
#[test]
#[ignore]
fn test_year_divisible_by_2_not_divisible_by_4_in_common_year() {
process_leapyear_case(1970, false);
}
#[test]
#[ignore]
fn test_year_divisible_by_4_not_divisible_by_100_leap_year() {
process_leapyear_case(1996, true);
}
#[test]
#[ignore]
fn test_year_divisible_by_4_and_5_is_still_a_leap_year() {
process_leapyear_case(1960, true);
}
#[test]
#[ignore]
fn test_year_divisible_by_100_not_divisible_by_400_common_year() {
process_leapyear_case(2100, false);
}
#[test]
#[ignore]
fn test_year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year() {
process_leapyear_case(1900, false);
}
#[test]
#[ignore]
fn test_year_divisible_by_400_leap_year() {
process_leapyear_case(2000, true);
}
#[test]
#[ignore]
fn test_year_divisible_by_400_but_not_by_125_is_still_a_leap_year() {
process_leapyear_case(2400, true);
}
#[test]
#[ignore]
fn test_year_divisible_by_200_not_divisible_by_400_common_year() {
process_leapyear_case(1800, false);
}
#[test]
#[ignore]
fn test_any_old_year() {
process_leapyear_case(1997, false);
}
#[test]
#[ignore]
fn test_early_years() {
process_leapyear_case(1, false);
process_leapyear_case(4, true);
@ -72,7 +62,6 @@ fn test_early_years() {
}
#[test]
#[ignore]
fn test_century() {
process_leapyear_case(1700, false);
process_leapyear_case(1800, false);
@ -80,7 +69,6 @@ fn test_century() {
}
#[test]
#[ignore]
fn test_exceptional_centuries() {
process_leapyear_case(1600, true);
process_leapyear_case(2000, true);
@ -88,7 +76,6 @@ fn test_exceptional_centuries() {
}
#[test]
#[ignore]
fn test_years_1600_to_1699() {
let incorrect_years = (1600..1700)
.filter(|&year| leap::is_leap_year(year) != (year % 4 == 0))