|
|
@ -34,4 +34,30 @@ public class BirthdateTest extends TestCase { |
|
|
|
assertEquals(2001, b.getYear()); |
|
|
|
} |
|
|
|
|
|
|
|
public void test_rejectInvalidBirthday() { |
|
|
|
Birthdate birthdate = new Birthdate(0, 0, 0); |
|
|
|
boolean expectedResult = false; |
|
|
|
boolean gotResult = birthdate.isValid(0, 0, 0); |
|
|
|
assertEquals(expectedResult, gotResult); |
|
|
|
|
|
|
|
gotResult = birthdate.isValid(32, 13, 1990); |
|
|
|
assertEquals(expectedResult, gotResult); |
|
|
|
|
|
|
|
gotResult = birthdate.isValid(31, 0, 1980); |
|
|
|
assertEquals(expectedResult, gotResult); |
|
|
|
|
|
|
|
gotResult = birthdate.isValid(31, 13, 1980); |
|
|
|
assertEquals(expectedResult, gotResult); |
|
|
|
|
|
|
|
gotResult = birthdate.isValid(1, 1, 3000); |
|
|
|
assertEquals(expectedResult, gotResult); |
|
|
|
|
|
|
|
gotResult = birthdate.isValid(1, 1, 1900); |
|
|
|
assertEquals(expectedResult, gotResult); |
|
|
|
|
|
|
|
expectedResult = true; |
|
|
|
gotResult = birthdate.isValid(1, 5, 2020); |
|
|
|
assertEquals(expectedResult, gotResult); |
|
|
|
} |
|
|
|
|
|
|
|
} |