@Test public void testBuilderMethods() { Ipv4 sample = new Ipv4(1l); assertEquals(sample, Ipv4.of(BigInteger.ONE)); assertEquals(sample, Ipv4.of(1l)); assertEquals(sample, Ipv4.of("0.0.0.1")); }
@Test public void shouldCalculateCommonPrefixLength() { Ipv4 ipv4 = Ipv4.of("192.168.0.0"); assertEquals(0, ipv4.getCommonPrefixLength(Ipv4.of("0.0.0.0"))); assertEquals(16, ipv4.getCommonPrefixLength(Ipv4.of("192.168.255.255"))); assertEquals(32, ipv4.getCommonPrefixLength(Ipv4.of("192.168.0.0"))); }
@Test public void testHasPrevious() { assertFalse(Ipv4.FIRST_IPV4_ADDRESS.hasPrevious()); assertTrue(Ipv4.of("192.168.0.1").hasPrevious()); assertTrue(Ipv4.LAST_IPV4_ADDRESS.hasPrevious()); }
@Test public void testBuilderWithNull() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("from cannot be null"); Ipv4.of((BigInteger) null); }