package net.ripe.commons.ip.range.compare;

import static junit.framework.Assert.*;
import net.ripe.commons.ip.range.AsnRange;
import net.ripe.commons.ip.resource.Asn;
import org.junit.Test;

public class StartAndSizeComparatorTest {

    private static final Asn _10 = Asn.of(10l);
    private static final Asn _9 = _10.previous();
    private static final Asn _11 = _10.next();
    private static final Asn _100 = Asn.of(100l);
    private static final Asn _99 = _100.previous();
    private static final Asn _101 = _100.next();

    private StartAndSizeComparator<Asn, AsnRange> comparator = new StartAndSizeComparator<Asn, AsnRange>();

    @Test
    public void testCompare() {
        // range      |----------|   [10, 100]
        // other      .|--------|.   [11, 99]
        // other      .|---------|   [11, 100]
        // other     |-----------|   [9, 100]
        // other     |------------|  [9, 101]
        // other      |---------|.   [10, 99]
        // other      |----------|   [10, 100]
        // other      |-----------|  [10, 101]
        AsnRange range = AsnRange.from(_10).to(_100);
        assertLessThan(range, AsnRange.from(_11).to(_99));
        assertLessThan(range, AsnRange.from(_11).to(_100));
        assertGreaterThan(range, AsnRange.from(_9).to(_100));
        assertGreaterThan(range, AsnRange.from(_9).to(_101));
        assertGreaterThan(range, AsnRange.from(_10).to(_99));
        assertEqual(range, AsnRange.from(_10).to(_100));
        assertLessThan(range, AsnRange.from(_10).to(_101));
    }

    private void assertLessThan(AsnRange range, AsnRange other) {
        assertTrue(comparator.compare(range, other) < 0);
    }

    private void assertGreaterThan(AsnRange range, AsnRange other) {
        assertTrue(comparator.compare(range, other) > 0);
    }

    private void assertEqual(AsnRange range, AsnRange other) {
        assertTrue(comparator.compare(range, other) == 0);
    }
}

@@ -812,24 +812,116 @@
   %5B11, 100%5D%0A
+        // other      .%7C----------%7C  %5B11, 101%5D%0A        // other     %7C----------%7C.   %5B9, 99%5D%0A
         // o
@@ -1305,32 +1305,153 @@
 _11).to(_100));%0A
+        assertLessThan(range, AsnRange.from(_11).to(_101));%0A        assertGreaterThan(range, AsnRange.from(_9).to(_99));%0A
         assertGr

Enhance unit test.