protected void verifyTransitiveComparison(T x, T y, T z) { assertNotNull(x); assertNotNull(y); assertNotNull(z); int x_y = x.compareTo(y); int y_z = y.compareTo(z); int x_z = x.compareTo(z); checkForMinMaxInt(x_y); checkForMinMaxInt(y_z); checkForMinMaxInt(x_z); if ((x_y > 0) && (y_z > 0)) { assertTrue(x_z > 0); } else if ((x_y < 0) && (y_z < 0)) { assertTrue(x_z < 0); } else { String msg = "Comparison of " + x.toString() + ", " + y.toString() + " and " + z.toString() + " is NOT Transitive. " + "Y must be 'between' X and Z."; assertTrue(msg, false); } }
protected void verifyComparableToVsEquals(T o1, T o2) { assertNotNull(o1); assertNotNull(o2); assertTrue((o1.compareTo(o2) == 0) == (o1.equals(o2))); assertTrue((o2.compareTo(o1) == 0) == (o2.equals(o1))); assertTrue((o1.compareTo(o2) == 0) == (o2.compareTo(o1) == 0)); }
protected void verifyComparableToDifferent(T o1, T o2) { assertNotNull(o1); assertNotNull(o2); int result = o1.compareTo(o2); checkForMinMaxInt(result); assertTrue(0 != signum(result)); }
protected void verifyComparableToEquivalent(T o1, T o2) { assertNotNull(o1); assertNotNull(o2); int expected = 0; int result = o1.compareTo(o2); assertEquals(expected, signum(result)); }
protected void verifyComparableToSelf(T obj) { assertNotNull(obj); int expected = 0; int result = obj.compareTo(obj); checkForMinMaxInt(result); assertEquals(expected, signum(result)); }
protected void verifyComparableToNull(T obj) { assertNotNull(obj); try { obj.compareTo(null); String msg = "Expected NullPointerException was NOT thrown."; assertTrue(msg, false); } catch (NullPointerException ex) { // this is what the spec requires, so ignore the exception. assertNotNull(ex); } }