Skip to content

Commit

Permalink
change tests to assert whole year at once
Browse files Browse the repository at this point in the history
  • Loading branch information
dten committed Feb 27, 2023
1 parent 9e617a9 commit d0aa393
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/uk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,19 @@ mod tests {
} else {
365
};
for i in 0..days {
let date = jan1 + Duration::days(i);
let holiday = date.is_bankholiday();
let expected = $dates.contains(&(date.day(), date.month()));
assert!(expected == holiday,
format!("Expected {} for {} but got {}", expected, date, holiday));
assert_eq!(is_bankholiday(&date), holiday);
}
let bhs: Vec<_> = (0..days)
.map(|i| jan1 + Duration::days(i))
.filter_map(|date| {
if date.is_bankholiday() {
Some((date.day(), date.month()))
} else {
None
}
})
.collect();
assert_eq!($dates, bhs.as_slice());
}
}
};
}

test!(year_1999, 1999,
Expand Down

0 comments on commit d0aa393

Please sign in to comment.