correction couverture de test Date

This commit is contained in:
trochas
2025-12-05 13:00:29 +01:00
parent 001b3071c7
commit 0740268419
5 changed files with 191 additions and 28 deletions

View File

@@ -35,14 +35,13 @@ class Date implements Comparable<Date> {
int max_day = max_day(m, y);
if (d < max_day) {
return new Date(d + 1, m, y);
} else if (d == max_day) {
} else {
if (m == 12) {
return new Date(1, 1, y + 1);
} else {
return new Date(1, m + 1, y);
}
}
return null; // This line should never be reached
}
public Date previousDate() {
@@ -64,18 +63,16 @@ class Date implements Comparable<Date> {
if (other == null) {
throw new NullPointerException();
}
if (isValidDate(other.getDay(), other.getMonth(), other.getYear())) {
int cmpYear = Integer.compare(this.getYear(), other.getYear());
if (cmpYear != 0)
return cmpYear;
int cmpYear = Integer.compare(this.getYear(), other.getYear());
if (cmpYear != 0)
return cmpYear;
int cmpMonth = Integer.compare(this.getMonth(), other.getMonth());
if (cmpMonth != 0)
return cmpMonth;
int cmpMonth = Integer.compare(this.getMonth(), other.getMonth());
if (cmpMonth != 0)
return cmpMonth;
return Integer.compare(this.getDay(), other.getDay());
return Integer.compare(this.getDay(), other.getDay());
}
throw new IllegalArgumentException("The date to compare is not valid");
}
public int getDay() {