MCPcopy Create free account
hub / github.com/RealTimeGenomics/rtg-tools / testOrder

Method testOrder

src/test/java/com/rtg/util/TestUtils.java:302–318  ·  view source on GitHub ↗

Test the ordering of a set of objects. They should be ordered strictly monotonicly in the array. Also checks consistency of equals and hashCode with the ordering. This is the generic version. @param ator a comparator to use when doing test. @param compare an array of objects which should be in stric

(final Comparator<T> ator, final T[] compare, final boolean checkHash)

Source from the content-addressed store, hash-verified

300 * @param <T> type to compare.
301 */
302 public static <T> void testOrder(final Comparator<T> ator, final T[] compare, final boolean checkHash) {
303 for (int i = 0; i < compare.length; ++i) {
304 for (int j = 0; j < i; ++j) {
305 //System.err.println(i+":"+j);
306 Assert.assertTrue(ator + ":" + compare[j] + ":" + compare[i], ator.compare(compare[j], compare[i]) < 0);
307 Assert.assertFalse(compare[j].equals(compare[i]));
308 Assert.assertTrue(String.valueOf(ator.compare(compare[i], compare[j])), ator.compare(compare[i], compare[j]) > 0);
309 Assert.assertFalse(compare[i].equals(compare[j]));
310 if (checkHash) {
311 Assert.assertFalse(compare[i].hashCode() == compare[j].hashCode());
312 }
313 }
314 Assert.assertEquals(0, ator.compare(compare[i], compare[i]));
315 Assert.assertTrue(compare[i].equals(compare[i]));
316 Assert.assertFalse(compare[i].equals(null));
317 }
318 }
319
320 /**
321 * Test the ordering of a set of comparable objects.

Callers 3

testComparatorMethod · 0.95
testOrderingMethod · 0.95
testCompareToMethod · 0.95

Calls 10

testEquivalentMethod · 0.95
testLessMethod · 0.95
assertTrueMethod · 0.80
assertFalseMethod · 0.80
compareMethod · 0.65
equalsMethod · 0.45
valueOfMethod · 0.45
hashCodeMethod · 0.45
assertEqualsMethod · 0.45
compareToMethod · 0.45

Tested by

no test coverage detected