#700 AtomContainerComparator should not be tested with Object

cdk-1.2.x
closed
9
2012-11-03
2008-08-10
Rajarshi Guha
No

In AtomContainerComparatorTest the method

testCompare_Object_Object

tries to perform the following type of checks:

Assert.assertEquals("object <-> cycloPentane", -1, comparator.compare(object, cycloPentane));

However this will always fail since Object cannot be cast to IAtomContainer, yet the comparator is defined to implement Comparator<IAtomContainer>

As a result during instantiation, the class cast is attemtped and fails.

The conclusion is that Object cannot be compared to IAtomContainer due to the definition of the comparator.

As a result, the tests should either be removed or instead should be rewritten to make sure that the ClassCastException occurs

Discussion