I'm using com.google.common.collect.ComparatorChain
to implement a custom comparator for different objects.
Now, the following tests fails, but why?
@Test
public void chainTest() {
ComparisonChain comparator = ComparisonChain.start()
.compare("a", "a");
assertTrue(comparator.result() == 0);
comparator.compare("a", "b");
assertTrue(comparator.result() != 0); //fails with AssertionError
}
Afaik the 2nd result should actually be != 0
as a != b
?
I could of course reassign the comparator like:
comparator = comparator.compare("a", "b");
But that would discard any results that were optained before the reassignment.