@Test public void testZeroZero() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation(0, null); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation(0, null); Assert.assertEquals(0, first.compareTo(second)); }
@Test public void testIsPrefixZeroZero() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation(0, null); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation(0, null); Assert.assertFalse(first.isPrefixOf(second)); Assert.assertFalse(second.isPrefixOf(first)); }
@Test public void testIsPrefixZeroEight() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation(0, null); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation(8, new byte[] {(byte) 0xa8}); Assert.assertTrue(first.isPrefixOf(second)); Assert.assertFalse(second.isPrefixOf(first)); }
@Test public void testNonZeroZero() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation( 20, new byte[] {(byte) 0xc0, (byte) 0xc0, (byte) 0xc0}); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation(0, null); Assert.assertEquals(1, first.compareTo(second)); }
@Test public void testCompareGreaterThirteenTwelveBits() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation(13, new byte[] {(byte) 0xc0, (byte) 0xc0}); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation(12, new byte[] {(byte) 0xc0, (byte) 0xc0}); Assert.assertEquals(1, first.compareTo(second)); }
@Test public void testCompareGreaterFiveForBits() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation(5, new byte[] {(byte) 0xc0}); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation(4, new byte[] {(byte) 0xc0}); Assert.assertEquals(1, first.compareTo(second)); }
@Test public void testCompareSmallerTwelveBitsSecond() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation(12, new byte[] {(byte) 0xc0, (byte) 0x00}); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation(12, new byte[] {(byte) 0xc0, (byte) 0xd0}); Assert.assertEquals(-1, first.compareTo(second)); }
@Test public void testCompareEqualsSmallerBits() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation(4, new byte[] {(byte) 0xc0}); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation(4, new byte[] {(byte) 0xd0}); Assert.assertEquals(-1, first.compareTo(second)); }
@Test public void testIsNoPrefixEightSixteen() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation(8, new byte[] {(byte) 0xc0}); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation(16, new byte[] {(byte) 0xc8, (byte) 0xa8}); Assert.assertFalse(first.isPrefixOf(second)); Assert.assertFalse(second.isPrefixOf(first)); }
@Test public void testIsPrefixFourFive() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation(4, new byte[] {(byte) 0xa0}); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation(5, new byte[] {(byte) 0xa8}); Assert.assertTrue(first.isPrefixOf(second)); Assert.assertFalse(second.isPrefixOf(first)); }
@Test public void testCompareGreaterTwentyoneTwentyBits() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation( 21, new byte[] {(byte) 0xc0, (byte) 0xc0, (byte) 0xc0}); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation( 20, new byte[] {(byte) 0xc0, (byte) 0xc0, (byte) 0xc0}); Assert.assertEquals(1, first.compareTo(second)); }
@Test public void testIsPrefixThirtyThirtytwo() { NetworkLayerReachabilityInformation first = new NetworkLayerReachabilityInformation( 30, new byte[] {(byte) 0xc8, (byte) 0xa8, 0x09, 0x04}); NetworkLayerReachabilityInformation second = new NetworkLayerReachabilityInformation( 32, new byte[] {(byte) 0xc8, (byte) 0xa8, 0x09, 0x07}); Assert.assertTrue(first.isPrefixOf(second)); Assert.assertFalse(second.isPrefixOf(first)); }