|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.smartics.util.test.theories.CompareToTheory<T>
T
- the type of the comparable to test here.
public abstract class CompareToTheory<T extends Comparable<T>>
Tests theory on comparable instances.
Constructor Summary | |
---|---|
CompareToTheory() |
Method Summary | |
---|---|
protected boolean |
checkConsistentWithEquals() Determines whether or not the theory should check the Comparable.compareTo(Object) is consistent with Object.equals(Object) . |
void |
compareToIsConsistentToEquals(T uutX, T uutY) Checks the optional consistent to equals property of the Comparable.compareTo(Object) method. |
void |
compareToIsSymmetric(T uutX, T uutY) Checks the symmetric property of the Comparable.compareTo(Object) method. |
void |
compareToIsTransitive(T uutX, T uutY, T uutZ) Checks the transitive property of the Comparable.compareTo(Object) method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CompareToTheory()
Method Detail |
---|
protected boolean checkConsistentWithEquals()
Comparable.compareTo(Object)
is consistent with
Object.equals(Object)
.
Override this method by your subclass.
true
per default.
public void compareToIsSymmetric(T uutX, T uutY)
Comparable.compareTo(Object)
method.
The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)
uutX
- the unit under test to test for symmetry.
uutY
- the unit under test to test for symmetry.
Comparable.compareTo(Object)
public final void compareToIsTransitive(T uutX, T uutY, T uutZ)
Comparable.compareTo(Object)
method.
The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.
Finally, the implementor must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.
uutX
- the unit under test to test for transitivity.
uutY
- the unit under test to test for transitivity.
uutZ
- the unit under test to test for transitivity.
Comparable.compareTo(Object)
public final void compareToIsConsistentToEquals(T uutX, T uutY)
Comparable.compareTo(Object)
method.
It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals."
uutX
- the unit under test to test for consistency with equals.
uutY
- the unit under test to test for consistency with equals.
Comparable.compareTo(Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |