Skip to content

Instantly share code, notes, and snippets.

@olafleur
Created October 9, 2015 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olafleur/d753dc74ed589ce18ff8 to your computer and use it in GitHub Desktop.
Save olafleur/d753dc74ed589ce18ff8 to your computer and use it in GitHub Desktop.
@Test
public void 2001_isCommon() {
boolean result = isLeapYear(2001);
assertThat(result).isFalse();
}
@Test
public void 1996_isLeap() {
boolean result = isLeapYear(1996);
assertThat(result).isTrue();
}
// more test cases until there are enough to triangulate all the possible scenarios
boolean isLeapYear(int year) {
return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment