Skip to content

Commit

Permalink
fix: Minute.equals() not correctly taking the day into account #318
Browse files Browse the repository at this point in the history
  • Loading branch information
jfree committed Oct 10, 2022
1 parent f7e307e commit f3974d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/jfree/data/time/Minute.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ public class Minute extends RegularTimePeriod implements Serializable {
public static final int LAST_MINUTE_IN_HOUR = 59;

/** The day. */
private Day day;
private final Day day;

/** The hour in which the minute falls. */
private byte hour;
private final byte hour;

/** The minute. */
private byte minute;
private final byte minute;

/** The first millisecond. */
private long firstMillisecond;
Expand Down Expand Up @@ -381,7 +381,7 @@ public boolean equals(Object obj) {
if (this.hour != that.hour) {
return false;
}
return true;
return this.day.equals(that.day);
}

/**
Expand Down
14 changes: 9 additions & 5 deletions src/test/java/org/jfree/data/time/MinuteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@

package org.jfree.data.time;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.time.ZoneOffset;
import java.util.Calendar;
import java.util.Date;
Expand All @@ -54,6 +49,8 @@

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
* Tests for the {@link Minute} class.
*/
Expand Down Expand Up @@ -84,6 +81,13 @@ public void testEquals() {
assertEquals(minute1, minute2);
}

@Test
public void comparison() {
Minute m1 = new Minute(30, 6, 10, 8, 2021);
Minute m2 = new Minute(30, 6, 11, 8, 2021);
assertNotEquals(m1, m2);
}

/**
* In GMT, the 4.55pm on 21 Mar 2002 is java.util.Date(1016729700000L).
* Use this to check the Minute constructor.
Expand Down

0 comments on commit f3974d7

Please sign in to comment.