-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds test for forPackage with recursive data structures
- Loading branch information
Showing
4 changed files
with
104 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
...src/test/java/nl/jqno/equalsverifier/testhelpers/packages/somerecursive/Nonrecursive.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,31 @@ | ||
package nl.jqno.equalsverifier.testhelpers.packages.somerecursive; | ||
|
||
public final class Nonrecursive { | ||
|
||
private final int x; | ||
private final int y; | ||
|
||
public Nonrecursive(int x, int y) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof Nonrecursive)) { | ||
return false; | ||
} | ||
Nonrecursive p = (Nonrecursive) obj; | ||
return p.x == x && p.y == y; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return x + (31 * y); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + ":" + x + "," + y; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...e/src/test/java/nl/jqno/equalsverifier/testhelpers/packages/somerecursive/RecursiveA.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,31 @@ | ||
package nl.jqno.equalsverifier.testhelpers.packages.somerecursive; | ||
|
||
import java.util.Objects; | ||
|
||
public final class RecursiveA { | ||
|
||
private final RecursiveB b; | ||
|
||
public RecursiveA(RecursiveB b) { | ||
this.b = b; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof RecursiveA)) { | ||
return false; | ||
} | ||
RecursiveA p = (RecursiveA) obj; | ||
return Objects.equals(b, p.b); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(b); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + ":" + b; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...e/src/test/java/nl/jqno/equalsverifier/testhelpers/packages/somerecursive/RecursiveB.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,31 @@ | ||
package nl.jqno.equalsverifier.testhelpers.packages.somerecursive; | ||
|
||
import java.util.Objects; | ||
|
||
public final class RecursiveB { | ||
|
||
private final RecursiveA a; | ||
|
||
public RecursiveB(RecursiveA a) { | ||
this.a = a; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof RecursiveB)) { | ||
return false; | ||
} | ||
RecursiveB p = (RecursiveB) obj; | ||
return Objects.equals(a, p.a); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(a); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + ":" + a; | ||
} | ||
} |