|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.smartics.util.test.theories.ObjectTheories
public abstract class ObjectTheories
Tests common object theories. This includes
Field Summary | |
---|---|
static int |
DEFAULT_COUNT_CONSISTENCY_CHECK The default value for the number of iterations for the consistency check . |
static boolean |
DEFAULT_RUN_EQUALS_THEORY_ON_DIFFERENT_TYPES The default value to be returned by checkForDifferentTypesInEquals() . |
static boolean |
DEFAULT_RUN_HASH_CODE_THEORY_ON_UNEQUAL_INSTANCES The default value to be returned by checkForUnequalHashCodes() . |
Constructor Summary | |
---|---|
ObjectTheories() |
Method Summary | |
---|---|
protected boolean |
checkForDifferentTypesInEquals() Determines if a theory to check that equals fails on different types should be checked. |
protected boolean |
checkForUnequalHashCodes() Determines if a theory to check for unequal hash code values for unequal instances should be checked. |
void |
equalsIsConsistent(Object uutX, Object uutY) Checks the consistent property of the Object.equals(Object) method. |
void |
equalsIsReflexive(Object uut) Checks the reflexive property of the Object.equals(Object) method. |
void |
equalsIsSymmetric(Object uutX, Object uutY) Checks the symmetric property of the Object.equals(Object) method. |
void |
equalsIsTransitive(Object uutX, Object uutY, Object uutZ) Checks the transitive property of the Object.equals(Object) method. |
void |
equalsReturnFalseOnInstanceOfOtherType(Object uut) Checks the consistent property of the Object.equals(Object) method regarding comparison with elements of other type. |
void |
equalsReturnFalseOnNull(Object uut) Checks the not-null property of the Object.equals(Object) method. |
protected int |
getConsistencyIterationCount() Determines the default number of iterations to go through for the consistency checks. |
protected int |
getEqualsConsistencyIterationCount() Determines the number of iterations to go through for the equals consistency check . |
protected int |
getHashCodeConsistencyIterationCount() Determines the number of iterations to go through for the hash code consistency check . |
void |
hashCodeIsConsistent(Object uut) Checks the consistency property of the Object.hashCode() method. |
void |
hashCodeIsConsistentWithEquals(Object uutX, Object uutY) Checks the consistency-with-equals property of the Object.hashCode() method. |
void |
hashCodeProducesUnequalHashCodesForUnequalInstances(Object uutX, Object uutY) Checks the guideline for optimum performance of the Object.hashCode() method. |
void |
toStringRunsWithoutFailure(Object uut) This theory simply checks that calling the Object.toString() method of the unit under test (UUT) does not fail with raising an exception. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_COUNT_CONSISTENCY_CHECK
consistency check
. May be specified by subclasses by overriding
getConsistencyIterationCount()
.
The value of this constant is 7.
7
public static final boolean DEFAULT_RUN_EQUALS_THEORY_ON_DIFFERENT_TYPES
checkForDifferentTypesInEquals()
.
The value of this constant is true.
true
public static final boolean DEFAULT_RUN_HASH_CODE_THEORY_ON_UNEQUAL_INSTANCES
checkForUnequalHashCodes()
.
The value of this constant is false.
false
Constructor Detail |
---|
public ObjectTheories()
Method Detail |
---|
protected int getConsistencyIterationCount()
getEqualsConsistencyIterationCount()
,
getHashCodeConsistencyIterationCount()
protected int getEqualsConsistencyIterationCount()
equals consistency check
.
getConsistencyIterationCount()
per default.
protected int getHashCodeConsistencyIterationCount()
hash code consistency check
.
getConsistencyIterationCount()
per default.
protected boolean checkForDifferentTypesInEquals()
true
if the theory should be executed,
false
otherwise. Per default returns
true
protected boolean checkForUnequalHashCodes()
true
if the theory should be executed,
false
otherwise. Per default returns
false
public final void equalsIsReflexive(Object uut)
Object.equals(Object)
method.
It is reflexive: for any non-null reference value
x
,x.equals(x)
should returntrue
.
uut
- the unit under test.
Object.equals(Object)
public final void equalsIsSymmetric(Object uutX, Object uutY)
Object.equals(Object)
method.
It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
.
uutX
- the unit under test to test for symmetry.
uutY
- the unit under test to test for symmetry.
Object.equals(Object)
public final void equalsIsTransitive(Object uutX, Object uutY, Object uutZ)
Object.equals(Object)
method.
It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
.
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.
Object.equals(Object)
public final void equalsIsConsistent(Object uutX, Object uutY)
Object.equals(Object)
method.
It is consistent: for any non-null reference values
x
andy
, multiple invocations of x.equals(y) consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified.
uutX
- the unit under test to test for consistency.
uutY
- the unit under test to test for consistency.
Object.equals(Object)
public final void equalsReturnFalseOnNull(Object uut)
Object.equals(Object)
method.
For any non-null reference value
x
,x.equals(null)
should returnfalse
.
uut
- the unit under test.
Object.equals(Object)
public final void equalsReturnFalseOnInstanceOfOtherType(Object uut)
Object.equals(Object)
method regarding comparison with elements of other type.
uut
- the unit under test.
Object.equals(Object)
public final void hashCodeIsConsistent(Object uut)
Object.hashCode()
method.
Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
uut
- the unit under test.
Object.hashCode()
public final void hashCodeIsConsistentWithEquals(Object uutX, Object uutY)
Object.hashCode()
method.
If two objects are equal according to the equals(Object) method, then calling the
hashCode
method on each of the two objects must produce the same integer result.
uutX
- the unit under test to test for consistency-with-equals.
uutY
- the unit under test to test for consistency-with-equals.
Object.hashCode()
public final void hashCodeProducesUnequalHashCodesForUnequalInstances(Object uutX, Object uutY)
Object.hashCode()
method.
It is not required that if two objects are unequal according to the
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.
uutX
- the unit under test.
uutY
- the unit under test.
Object.hashCode()
public final void toStringRunsWithoutFailure(Object uut)
Object.toString()
method of the unit under test (UUT) does not fail with raising an exception.
The theory is only executed on UUTs that are not null
.
uut
- the unit under test.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |