Skip to content

Commit

Permalink
Ports back some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Dec 5, 2024
1 parent 17871bc commit 7da2273
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,30 @@ public int hashCode() {
}
}

static final class Generic<T> {

private final T t;

public Generic(T t) {
this.t = t;
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Generic)) {
return false;
}
@SuppressWarnings("unchecked")
Generic<T> other = (Generic<T>) obj;
return Objects.equals(t, other.t);
}

@Override
public int hashCode() {
return Objects.hash(t);
}
}

static final class JavaGenericTypeContainer {

private final Optional<Point> optional;
Expand Down Expand Up @@ -218,30 +242,6 @@ public String toString() {
}
}

static final class Generic<T> {

private final T t;

public Generic(T t) {
this.t = t;
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Generic)) {
return false;
}
@SuppressWarnings("unchecked")
Generic<T> other = (Generic<T>) obj;
return Objects.equals(t, other.t);
}

@Override
public int hashCode() {
return Objects.hash(t);
}
}

static final class ListContainer {

private final List<Point> list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,27 @@ public void individuallySuppressedWarningsAreNotAddedGlobally() {
public void individuallyAddedPrefabValuesAreNotAddedGlobally() {
ConfiguredEqualsVerifier ev = EqualsVerifier.configure();

// should succeed
ev
.forClasses(RecursiveTypeContainer.class, A.class)
.withPrefabValues(
RecursiveType.class,
new RecursiveType(null),
new RecursiveType(new RecursiveType(null))
)
.verify();

// PrefabValues are not added to configuration, so should fail
ExpectedException
.when(() -> ev.forClasses(RecursiveTypeContainer.class, A.class).verify())
.assertFailure()
.assertMessageContains("Recursive datastructure");
}

@Test
public void individuallyAddedGenericPrefabValuesAreNotAddedGlobally() {
ConfiguredEqualsVerifier ev = EqualsVerifier.configure();

// should succeed
ev
.forClasses(SingleGenericContainerContainer.class, A.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,27 @@ public void individuallySuppressedWarningsAreNotAddedGlobally() {
public void individuallyAddedPrefabValuesAreNotAddedGlobally() {
ConfiguredEqualsVerifier ev = EqualsVerifier.configure();

// should succeed
ev
.forClass(RecursiveTypeContainer.class)
.withPrefabValues(
RecursiveType.class,
new RecursiveType(null),
new RecursiveType(new RecursiveType(null))
)
.verify();

// PrefabValues are not added to configuration, so should fail
ExpectedException
.when(() -> ev.forClass(RecursiveTypeContainer.class).verify())
.assertFailure()
.assertMessageContains("Recursive datastructure");
}

@Test
public void individuallyAddedGenericPrefabValuesAreNotAddedGlobally() {
ConfiguredEqualsVerifier ev = EqualsVerifier.configure();

// should succeed
ev
.forClass(SingleGenericContainerContainer.class)
Expand Down

0 comments on commit 7da2273

Please sign in to comment.