Skip to content

Commit

Permalink
test(leap-year): test property years not divisible by 4 are not leap …
Browse files Browse the repository at this point in the history
…years
  • Loading branch information
benjaminrae committed Jul 29, 2024
1 parent ed4a178 commit 5ed8b3e
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ public void yearsDivisibleBy4And100ButNot400AreNotLeapYears(@ForAll("yearsDivisi
assertThat(year).isNotLeap();
}

@Property
public void yearsNotDivisibleBy4AreNotLeapYears(@ForAll @Positive int yearsNotDivisibleBy4) {
Assume.that(isNotDivisibleBy4(yearsNotDivisibleBy4));
Year year = new Year(yearsNotDivisibleBy4);

assertThat(year).isNotLeap();
}

private static boolean isNotDivisibleBy4(int yearsNotDivisibleBy4) {
return yearsNotDivisibleBy4 % 4 != 0;
}

@Provide
private Arbitrary<Integer> yearsDivisibleBy400() {
return Arbitraries.integers().between(1, 10000).map(year -> year * 400);
Expand Down

0 comments on commit 5ed8b3e

Please sign in to comment.