Package com.google.common.testing
Class RelationshipTester<T>
- java.lang.Object
-
- com.google.common.testing.RelationshipTester<T>
-
@GwtCompatible final class RelationshipTester<T> extends java.lang.Object
Implementation helper forEqualsTesterandEquivalenceTesterthat tests for equivalence classes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classRelationshipTester.Item<T>(package private) static classRelationshipTester.ItemReporter
-
Field Summary
Fields Modifier and Type Field Description private Equivalence<? super T>equivalenceA word about usingEquivalence, which automatically checks fornulland identical inputs: This sounds like it ought to be a problem here, since the goals of this class include testing thatequals()is reflexive and is tolerant ofnull.private java.util.List<ImmutableList<T>>groupsprivate java.lang.StringhashNameprivate RelationshipTester.ItemReporteritemReporterprivate java.lang.StringrelationshipName
-
Constructor Summary
Constructors Constructor Description RelationshipTester(Equivalence<? super T> equivalence, java.lang.String relationshipName, java.lang.String hashName, RelationshipTester.ItemReporter itemReporter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RelationshipTester<T>addRelatedGroup(java.lang.Iterable<? extends T> group)private voidassertRelated(int groupNumber, int itemNumber, int relatedItemNumber)private voidassertUnrelated(int groupNumber, int itemNumber, int unrelatedGroupNumber, int unrelatedItemNumber)private voidassertWithTemplate(java.lang.String template, RelationshipTester.Item<T> item, RelationshipTester.Item<T> other, boolean condition)private RelationshipTester.Item<T>getItem(int groupNumber, int itemNumber)voidtest()
-
-
-
Field Detail
-
equivalence
private final Equivalence<? super T> equivalence
A word about usingEquivalence, which automatically checks fornulland identical inputs: This sounds like it ought to be a problem here, since the goals of this class include testing thatequals()is reflexive and is tolerant ofnull. However, there's no problem. The reason:EqualsTestertestsnulland identical inputs directly againstequals()rather than through theEquivalence.
-
relationshipName
private final java.lang.String relationshipName
-
hashName
private final java.lang.String hashName
-
itemReporter
private final RelationshipTester.ItemReporter itemReporter
-
groups
private final java.util.List<ImmutableList<T>> groups
-
-
Constructor Detail
-
RelationshipTester
RelationshipTester(Equivalence<? super T> equivalence, java.lang.String relationshipName, java.lang.String hashName, RelationshipTester.ItemReporter itemReporter)
-
-
Method Detail
-
addRelatedGroup
public RelationshipTester<T> addRelatedGroup(java.lang.Iterable<? extends T> group)
-
test
public void test()
-
assertRelated
private void assertRelated(int groupNumber, int itemNumber, int relatedItemNumber)
-
assertUnrelated
private void assertUnrelated(int groupNumber, int itemNumber, int unrelatedGroupNumber, int unrelatedItemNumber)
-
assertWithTemplate
private void assertWithTemplate(java.lang.String template, RelationshipTester.Item<T> item, RelationshipTester.Item<T> other, boolean condition)
-
getItem
private RelationshipTester.Item<T> getItem(int groupNumber, int itemNumber)
-
-