Skip to content

Instantly share code, notes, and snippets.

@beyondxscratch
Created July 14, 2022 22:23
Show Gist options
  • Save beyondxscratch/6c3a134c6f40a391819a13be11900252 to your computer and use it in GitHub Desktop.
Save beyondxscratch/6c3a134c6f40a391819a13be11900252 to your computer and use it in GitHub Desktop.
public interface EqualityTest<T> {
T createValue();
T createOtherValue();
@Test
default void should_be_equal() {
assertThat(createValue()).isEqualTo(createValue());
assertThat(createValue().hashCode()).isEqualTo(createValue().hashCode());
}
@Test
default void should_not_be_equal() {
assertThat(createValue()).isNotEqualTo(createOtherValue());
assertThat(createValue().hashCode()).isNotEqualTo(createOtherValue().hashCode());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment