コード例 #1
0
 @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"));
 }
コード例 #2
0
 @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")));
 }
コード例 #3
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());
 }
コード例 #4
0
 @Test
 public void testBuilderWithNull() {
   thrown.expect(IllegalArgumentException.class);
   thrown.expectMessage("from cannot be null");
   Ipv4.of((BigInteger) null);
 }