-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Cleanup T2 equals() and add test
Showing
2 changed files
with
35 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/test/java/org/opentripplanner/common/model/T2Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.opentripplanner.common.model; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class T2Test { | ||
|
||
@Test | ||
void testEquals() { | ||
var subject = new T2<>("Alf", 1); | ||
|
||
assertEquals(new T2<>("Alf", 1), subject); | ||
assertEquals(new T2<>("Alf", 1).hashCode(), subject.hashCode()); | ||
|
||
// first is different | ||
assertNotEquals(new T2<>("Alfi", 1), subject); | ||
|
||
// second is different | ||
assertNotEquals(new T2<>("Alf", 2), subject); | ||
|
||
// Different types, should not fail with exception | ||
assertNotEquals(new T2<>(1, "Alf"), subject); | ||
} | ||
|
||
@Test | ||
void testToString() { | ||
var subject = new T2<>("Alf", 1); | ||
assertEquals("T2(Alf, 1)", subject.toString()); | ||
} | ||
} |