-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not consider null in equality checks
- Loading branch information
Henry Coles
committed
May 17, 2022
1 parent
bd820bb
commit fbc3215
Showing
5 changed files
with
71 additions
and
44 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
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
33 changes: 33 additions & 0 deletions
33
pitest-entry/src/main/java/org/pitest/sequence/StateContext.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,33 @@ | ||
package org.pitest.sequence; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Pair class to hold state and context. | ||
*/ | ||
final class StateContext<T> { | ||
|
||
StateContext(State<T> state, Context context) { | ||
this.state = state; | ||
this.context = context; | ||
} | ||
final State<T> state; | ||
final Context context; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof StateContext)) { | ||
return false; | ||
} | ||
StateContext<?> that = (StateContext<?>) o; | ||
return state.equals(that.state) && context.equals(that.context); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(state, context); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
pitest-entry/src/test/java/org/pitest/sequence/ContextTest.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,16 @@ | ||
package org.pitest.sequence; | ||
|
||
import nl.jqno.equalsverifier.EqualsVerifier; | ||
import org.junit.Test; | ||
|
||
public class ContextTest { | ||
|
||
@Test | ||
public void obeysHashCodeEqualsContract() { | ||
EqualsVerifier.forClass(Context.class) | ||
.withNonnullFields("slots") | ||
.withIgnoredFields("debug") | ||
.verify(); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
pitest-entry/src/test/java/org/pitest/sequence/StateContextTest.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,13 @@ | ||
package org.pitest.sequence; | ||
|
||
import nl.jqno.equalsverifier.EqualsVerifier; | ||
import org.junit.Test; | ||
|
||
public class StateContextTest { | ||
@Test | ||
public void obeysHashCodeEqualsContract() { | ||
EqualsVerifier.forClass(StateContext.class) | ||
.withNonnullFields("state", "context") | ||
.verify(); | ||
} | ||
} |