Object secondary = congruenceClass.get(secondaryElementNumber); if (!primary.equals(secondary)) { errors.add(new PairCheckFailure(NOT_EQUAL, classNumber, primaryElementNumber, primary, classNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(NOT_EQUAL, classNumber, secondaryElementNumber, secondary, classNumber, primaryElementNumber, primary)); errors.add(new PairCheckFailure(COMPARE_NOT_EQUAL, classNumber, primaryElementNumber, errors.add(new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, classNumber, primaryElementNumber, primary, classNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(COMPARE_NOT_EQUAL, classNumber, secondaryElementNumber, errors.add(new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, classNumber, secondaryElementNumber, secondary, classNumber, primaryElementNumber, primary)); errors.add(new PairCheckFailure(HASH_CODE_NOT_SAME, classNumber, primaryElementNumber, primary, classNumber, secondaryElementNumber, secondary)); for (Object secondary : secondaryCongruenceClass) { if (primary.equals(secondary)) { errors.add(new PairCheckFailure(EQUAL, primaryClassNumber, primaryElementNumber, primary, secondaryClassNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(EQUAL, secondaryClassNumber, secondaryElementNumber, secondary, primaryClassNumber, primaryElementNumber, primary)); errors.add(new PairCheckFailure(COMPARE_EQUAL, primaryClassNumber, primaryElementNumber, primary, secondaryClassNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION,
Object secondary = congruenceClass.get(secondaryElementNumber); if (!primary.equals(secondary)) { errors.add(new PairCheckFailure(NOT_EQUAL, classNumber, primaryElementNumber, primary, classNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(NOT_EQUAL, classNumber, secondaryElementNumber, secondary, classNumber, primaryElementNumber, primary)); errors.add(new PairCheckFailure(COMPARE_NOT_EQUAL, classNumber, primaryElementNumber, errors.add(new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, classNumber, primaryElementNumber, primary, classNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(COMPARE_NOT_EQUAL, classNumber, secondaryElementNumber, errors.add(new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, classNumber, secondaryElementNumber, secondary, classNumber, primaryElementNumber, primary)); errors.add(new PairCheckFailure(HASH_CODE_NOT_SAME, classNumber, primaryElementNumber, primary, classNumber, secondaryElementNumber, secondary)); for (Object secondary : secondaryCongruenceClass) { if (primary.equals(secondary)) { errors.add(new PairCheckFailure(EQUAL, primaryClassNumber, primaryElementNumber, primary, secondaryClassNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(EQUAL, secondaryClassNumber, secondaryElementNumber, secondary, primaryClassNumber, primaryElementNumber, primary)); errors.add(new PairCheckFailure(COMPARE_EQUAL, primaryClassNumber, primaryElementNumber, primary, secondaryClassNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION,
Object secondary = congruenceClass.get(secondaryElementNumber); if (!primary.equals(secondary)) { errors.add(new PairCheckFailure(NOT_EQUAL, classNumber, primaryElementNumber, primary, classNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(NOT_EQUAL, classNumber, secondaryElementNumber, secondary, classNumber, primaryElementNumber, primary)); errors.add(new PairCheckFailure(COMPARE_NOT_EQUAL, classNumber, primaryElementNumber, errors.add(new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, classNumber, primaryElementNumber, primary, classNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(COMPARE_NOT_EQUAL, classNumber, secondaryElementNumber, errors.add(new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, classNumber, secondaryElementNumber, secondary, classNumber, primaryElementNumber, primary)); errors.add(new PairCheckFailure(HASH_CODE_NOT_SAME, classNumber, primaryElementNumber, primary, classNumber, secondaryElementNumber, secondary)); for (Object secondary : secondaryCongruenceClass) { if (primary.equals(secondary)) { errors.add(new PairCheckFailure(EQUAL, primaryClassNumber, primaryElementNumber, primary, secondaryClassNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(EQUAL, secondaryClassNumber, secondaryElementNumber, secondary, primaryClassNumber, primaryElementNumber, primary)); errors.add(new PairCheckFailure(COMPARE_EQUAL, primaryClassNumber, primaryElementNumber, primary, secondaryClassNumber, secondaryElementNumber, secondary)); errors.add(new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION,
new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 0, 1, "Hello", 0, 0, notComparable), new PairCheckFailure(NOT_EQUAL, 0, 0, notComparable, 0, 1, "Hello"), new PairCheckFailure(NOT_EQUAL, 0, 1, "Hello", 0, 0, notComparable), new PairCheckFailure(HASH_CODE_NOT_SAME, 0, 0, notComparable, 0, 1, "Hello")); new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 0, 0, "Hello", 0, 1, notComparable), new PairCheckFailure(NOT_EQUAL, 0, 0, "Hello", 0, 1, notComparable), new PairCheckFailure(NOT_EQUAL, 0, 1, notComparable, 0, 0, "Hello"), new PairCheckFailure(HASH_CODE_NOT_SAME, 0, 0, "Hello", 0, 1, notComparable)); new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 1, 0, "Hello", 0, 0, notComparable)); new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 0, 0, "Hello", 1, 0, notComparable));
new PairCheckFailure(NOT_LESS_THAN, 0, 0, 1, 1, 0, 0), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, 0, 0, 0, 1) ); new PairCheckFailure(NOT_LESS_THAN, 0, 0, "bob", 1, 0, "alice"), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, "alice", 0, 0, "bob") ); new PairCheckFailure(NOT_LESS_THAN, 0, 0, 1, 1, 0, 0), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, 0, 0, 0, 1), new PairCheckFailure(NOT_LESS_THAN, 0, 0, 1, 1, 1, 0), new PairCheckFailure(NOT_GREATER_THAN, 1, 1, 0, 0, 0, 1) ); new PairCheckFailure(NOT_LESS_THAN, 0, 0, "bob", 1, 0, "alice"), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, "alice", 0, 0, "bob"), new PairCheckFailure(NOT_LESS_THAN, 0, 0, "bob", 1, 1, "alice"), new PairCheckFailure(NOT_GREATER_THAN, 1, 1, "alice", 0, 0, "bob") );
new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 0, 1, "Hello", 0, 0, notComparable), new PairCheckFailure(NOT_EQUAL, 0, 0, notComparable, 0, 1, "Hello"), new PairCheckFailure(NOT_EQUAL, 0, 1, "Hello", 0, 0, notComparable), new PairCheckFailure(HASH_CODE_NOT_SAME, 0, 0, notComparable, 0, 1, "Hello") ); new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 0, 0, "Hello", 0, 1, notComparable), new PairCheckFailure(NOT_EQUAL, 0, 0, "Hello", 0, 1, notComparable), new PairCheckFailure(NOT_EQUAL, 0, 1, notComparable, 0, 0, "Hello"), new PairCheckFailure(HASH_CODE_NOT_SAME, 0, 0, "Hello", 0, 1, notComparable) ); new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 1, 0, "Hello", 0, 0, notComparable) ); new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 0, 0, "Hello", 1, 0, notComparable) );
new PairCheckFailure(NOT_LESS_THAN, 0, 0, 1, 1, 0, 0), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, 0, 0, 0, 1)); new PairCheckFailure(NOT_LESS_THAN, 0, 0, "bob", 1, 0, "alice"), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, "alice", 0, 0, "bob")); new PairCheckFailure(NOT_LESS_THAN, 0, 0, 1, 1, 0, 0), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, 0, 0, 0, 1), new PairCheckFailure(NOT_LESS_THAN, 0, 0, 1, 1, 1, 0), new PairCheckFailure(NOT_GREATER_THAN, 1, 1, 0, 0, 0, 1)); new PairCheckFailure(NOT_LESS_THAN, 0, 0, "bob", 1, 0, "alice"), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, "alice", 0, 0, "bob"), new PairCheckFailure(NOT_LESS_THAN, 0, 0, "bob", 1, 1, "alice"), new PairCheckFailure(NOT_GREATER_THAN, 1, 1, "alice", 0, 0, "bob"));
new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 0, 1, "Hello", 0, 0, notComparable), new PairCheckFailure(NOT_EQUAL, 0, 0, notComparable, 0, 1, "Hello"), new PairCheckFailure(NOT_EQUAL, 0, 1, "Hello", 0, 0, notComparable), new PairCheckFailure(HASH_CODE_NOT_SAME, 0, 0, notComparable, 0, 1, "Hello")); new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 0, 0, "Hello", 0, 1, notComparable), new PairCheckFailure(NOT_EQUAL, 0, 0, "Hello", 0, 1, notComparable), new PairCheckFailure(NOT_EQUAL, 0, 1, notComparable, 0, 0, "Hello"), new PairCheckFailure(HASH_CODE_NOT_SAME, 0, 0, "Hello", 0, 1, notComparable)); new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 1, 0, "Hello", 0, 0, notComparable)); new PairCheckFailure(COMPARE_CLASS_CAST_EXCEPTION, 0, 0, "Hello", 1, 0, notComparable));
new PairCheckFailure(NOT_LESS_THAN, 0, 0, 1, 1, 0, 0), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, 0, 0, 0, 1)); new PairCheckFailure(NOT_LESS_THAN, 0, 0, "bob", 1, 0, "alice"), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, "alice", 0, 0, "bob")); new PairCheckFailure(NOT_LESS_THAN, 0, 0, 1, 1, 0, 0), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, 0, 0, 0, 1), new PairCheckFailure(NOT_LESS_THAN, 0, 0, 1, 1, 1, 0), new PairCheckFailure(NOT_GREATER_THAN, 1, 1, 0, 0, 0, 1)); new PairCheckFailure(NOT_LESS_THAN, 0, 0, "bob", 1, 0, "alice"), new PairCheckFailure(NOT_GREATER_THAN, 1, 0, "alice", 0, 0, "bob"), new PairCheckFailure(NOT_LESS_THAN, 0, 0, "bob", 1, 1, "alice"), new PairCheckFailure(NOT_GREATER_THAN, 1, 1, "alice", 0, 0, "bob"));
try { if (lesser.compareTo(greater) >= 0) { builder.add(new PairCheckFailure(NOT_LESS_THAN, lesserClassNumber, lesserElementNumber, lesser, greaterClassNumber, greaterElementNumber, greater)); builder.add(new PairCheckFailure(NOT_GREATER_THAN, greaterClassNumber, greaterElementNumber, greater, lesserClassNumber, lesserElementNumber, lesser));
new PairCheckFailure(NOT_EQUAL, 1, 0, 1, 1, 1, 2), new PairCheckFailure(NOT_EQUAL, 1, 1, 2, 1, 0, 1), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 0, 1, 1, 1, 2), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 1, 2, 1, 0, 1), new PairCheckFailure(HASH_CODE_NOT_SAME, 1, 0, 1, 1, 1, 2) ); new PairCheckFailure(NOT_EQUAL, 1, 0, "bob", 1, 1, "charlie"), new PairCheckFailure(NOT_EQUAL, 1, 1, "charlie", 1, 0, "bob"), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 0, "bob", 1, 1, "charlie"), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 1, "charlie", 1, 0, "bob"), new PairCheckFailure(HASH_CODE_NOT_SAME, 1, 0, "bob", 1, 1, "charlie") );
try { if (lesser.compareTo(greater) >= 0) { builder.add(new PairCheckFailure(NOT_LESS_THAN, lesserClassNumber, lesserElementNumber, lesser, greaterClassNumber, greaterElementNumber, greater)); builder.add(new PairCheckFailure(NOT_GREATER_THAN, greaterClassNumber, greaterElementNumber, greater, lesserClassNumber, lesserElementNumber, lesser));
new PairCheckFailure(NOT_EQUAL, 1, 0, 1, 1, 1, 2), new PairCheckFailure(NOT_EQUAL, 1, 1, 2, 1, 0, 1), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 0, 1, 1, 1, 2), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 1, 2, 1, 0, 1), new PairCheckFailure(HASH_CODE_NOT_SAME, 1, 0, 1, 1, 1, 2)); new PairCheckFailure(NOT_EQUAL, 1, 0, "bob", 1, 1, "charlie"), new PairCheckFailure(NOT_EQUAL, 1, 1, "charlie", 1, 0, "bob"), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 0, "bob", 1, 1, "charlie"), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 1, "charlie", 1, 0, "bob"), new PairCheckFailure(HASH_CODE_NOT_SAME, 1, 0, "bob", 1, 1, "charlie"));
new PairCheckFailure(NOT_EQUAL, 1, 0, 1, 1, 1, 2), new PairCheckFailure(NOT_EQUAL, 1, 1, 2, 1, 0, 1), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 0, 1, 1, 1, 2), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 1, 2, 1, 0, 1), new PairCheckFailure(HASH_CODE_NOT_SAME, 1, 0, 1, 1, 1, 2)); new PairCheckFailure(NOT_EQUAL, 1, 0, "bob", 1, 1, "charlie"), new PairCheckFailure(NOT_EQUAL, 1, 1, "charlie", 1, 0, "bob"), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 0, "bob", 1, 1, "charlie"), new PairCheckFailure(COMPARE_NOT_EQUAL, 1, 1, "charlie", 1, 0, "bob"), new PairCheckFailure(HASH_CODE_NOT_SAME, 1, 0, "bob", 1, 1, "charlie"));
try { if (lesser.compareTo(greater) >= 0) { builder.add(new PairCheckFailure(NOT_LESS_THAN, lesserClassNumber, lesserElementNumber, lesser, greaterClassNumber, greaterElementNumber, greater)); builder.add(new PairCheckFailure(NOT_GREATER_THAN, greaterClassNumber, greaterElementNumber, greater, lesserClassNumber, lesserElementNumber, lesser));
@Test public void notEqual() { try { equivalenceTester() .addEquivalentGroup("foo") .addEquivalentGroup("foo") .check(); fail("Expected EquivalenceAssertionError"); } catch (EquivalenceAssertionError e) { assertEqualsIgnoreOrder( e.getFailures(), newArrayList( new PairCheckFailure(EQUAL, 0, 0, "foo", 1, 0, "foo"), new PairCheckFailure(EQUAL, 1, 0, "foo", 0, 0, "foo"), new PairCheckFailure(COMPARE_EQUAL, 0, 0, "foo", 1, 0, "foo"), new PairCheckFailure(COMPARE_EQUAL, 1, 0, "foo", 0, 0, "foo") ) ); } }
@Test public void notSymmetric() { NotSymmetric o1 = new NotSymmetric(1); NotSymmetric o2 = new NotSymmetric(2); NotSymmetric o3 = new NotSymmetric(3); try { equivalenceTester() .addEquivalentGroup(o1, o3, o2) .check(); fail("Expected EquivalenceAssertionError"); } catch (EquivalenceAssertionError e) { assertExpectedFailures(e, new PairCheckFailure(NOT_EQUAL, 0, 0, o1, 0, 1, o3), new PairCheckFailure(NOT_EQUAL, 0, 0, o1, 0, 2, o2), new PairCheckFailure(NOT_EQUAL, 0, 2, o2, 0, 1, o3)); } }
@Test public void comparableNotSymmetric() { ComparableNotSymmetric o1 = new ComparableNotSymmetric(1); ComparableNotSymmetric o2 = new ComparableNotSymmetric(2); ComparableNotSymmetric o3 = new ComparableNotSymmetric(3); try { equivalenceTester() .addEquivalentGroup(o1, o3, o2) .check(); fail("Expected EquivalenceAssertionError"); } catch (EquivalenceAssertionError e) { assertExpectedFailures(e, new PairCheckFailure(COMPARE_NOT_EQUAL, 0, 0, o1, 0, 1, o3), new PairCheckFailure(COMPARE_NOT_EQUAL, 0, 0, o1, 0, 2, o2), new PairCheckFailure(COMPARE_NOT_EQUAL, 0, 2, o2, 0, 1, o3)); } }
@Test public void notEqual() { try { equivalenceTester() .addEquivalentGroup("foo") .addEquivalentGroup("foo") .check(); fail("Expected EquivalenceAssertionError"); } catch (EquivalenceAssertionError e) { assertEqualsIgnoreOrder( e.getFailures(), newArrayList( new PairCheckFailure(EQUAL, 0, 0, "foo", 1, 0, "foo"), new PairCheckFailure(EQUAL, 1, 0, "foo", 0, 0, "foo"), new PairCheckFailure(COMPARE_EQUAL, 0, 0, "foo", 1, 0, "foo"), new PairCheckFailure(COMPARE_EQUAL, 1, 0, "foo", 0, 0, "foo"))); } }
@Test public void comparableNotSymmetric() { ComparableNotSymmetric o1 = new ComparableNotSymmetric(1); ComparableNotSymmetric o2 = new ComparableNotSymmetric(2); ComparableNotSymmetric o3 = new ComparableNotSymmetric(3); try { equivalenceTester() .addEquivalentGroup(o1, o3, o2) .check(); fail("Expected EquivalenceAssertionError"); } catch (EquivalenceAssertionError e) { assertExpectedFailures(e, new PairCheckFailure(COMPARE_NOT_EQUAL, 0, 0, o1, 0, 1, o3), new PairCheckFailure(COMPARE_NOT_EQUAL, 0, 0, o1, 0, 2, o2), new PairCheckFailure(COMPARE_NOT_EQUAL, 0, 2, o2, 0, 1, o3)); } }