@Test
public final void testComparison() {

    TestData td = TestData.getInstance();
    Line line1 = td.getMapDatabase().getLine(1);
    Line line2 = td.getMapDatabase().getLine(2);
    CandidateLine ratio1000 = new CandidateLine(null, RATIO_1000);
    CandidateLine ratio999a = new CandidateLine(line1, RATIO_999, 0);
    CandidateLine rds03 = new CandidateLine(line2, RATIO_400, Integer.MAX_VALUE);
    CandidateLine ratio999b = new CandidateLine(null, RATIO_999);
    CandidateLine maxRatio = new CandidateLine(null, Integer.MAX_VALUE);
    CandidateLine minRatio = new CandidateLine(line2, Integer.MIN_VALUE);
    CandidateLine rdsRatioZero = new CandidateLine(null, 0);
    CandidateLineComparator comp = new CandidateLineComparator();
    assertTrue(comp.compare(ratio1000, ratio999a) < 0);
    assertTrue(comp.compare(ratio999a, ratio1000) > 0);
    assertTrue(comp.compare(ratio1000, rds03) < 0);
    assertTrue(comp.compare(rds03, ratio999a) > 0);
    assertTrue(comp.compare(ratio999a, ratio999b) == 0);
    assertTrue(comp.compare(maxRatio, minRatio) < 0);
    assertTrue(comp.compare(minRatio, maxRatio) > 0);
    assertTrue(comp.compare(minRatio, rdsRatioZero) > 0);
    assertTrue(comp.compare(rdsRatioZero, rdsRatioZero) == 0);
    assertTrue(comp.compare(rdsRatioZero, rdsRatioZero) == 0);
    CandidateLine[] expectedSorting = new CandidateLine[]{
            maxRatio, ratio1000, ratio999a, rdsRatioZero, minRatio};
    List<CandidateLine> cLines = Arrays.asList(rdsRatioZero, minRatio,
            maxRatio, ratio999a, ratio1000);
    Collections.sort(cLines, new CandidateLineComparator());
    for (int i = 0; i < expectedSorting.length; i++) {
        assertSame(cLines.get(i), expectedSorting[i],
                "Unexpected entry at index " + i);
    }
}