@Test(dataProvider = "numberOfAddressDataProvider") public void numberOfAddress(String cidrAddress, int expected) { assertEquals(AddressUtils.numberOfAddress(cidrAddress), expected); }
public static long numberOfAddress(String cidrAddress) { SubnetInfo info = new SubnetUtils(cidrAddress).getInfo(); long lowestAddrAsLong = AddressUtils.ipv4ToLong(info.getNetworkAddress()); long highestAddrAsLong = AddressUtils.ipv4ToLong(info.getBroadcastAddress()); return (highestAddrAsLong - lowestAddrAsLong) + 1; }
AddressUtils { public static long numberOfAddress(String cidrAddress) { SubnetInfo info = new SubnetUtils(cidrAddress).getInfo(); long lowestAddrAsLong = AddressUtils.ipv4ToLong(info.getNetworkAddress()); long highestAddrAsLong = AddressUtils.ipv4ToLong(info.getBroadcastAddress()); return (highestAddrAsLong - lowestAddrAsLong) + 1; } }
AddressUtils { public static long numberOfAddress(String cidrAddress) { SubnetInfo info = new SubnetUtils(cidrAddress).getInfo(); long lowestAddrAsLong = AddressUtils.ipv4ToLong(info.getNetworkAddress()); long highestAddrAsLong = AddressUtils.ipv4ToLong(info.getBroadcastAddress()); return (highestAddrAsLong - lowestAddrAsLong) + 1; } private  AddressUtils(); }
AddressUtils { public static long numberOfAddress(String cidrAddress) { SubnetInfo info = new SubnetUtils(cidrAddress).getInfo(); long lowestAddrAsLong = AddressUtils.ipv4ToLong(info.getNetworkAddress()); long highestAddrAsLong = AddressUtils.ipv4ToLong(info.getBroadcastAddress()); return (highestAddrAsLong - lowestAddrAsLong) + 1; } private  AddressUtils(); static String longToIpv4(long ipAsLong); static long ipv4ToLong(String ipAsText); static String toCIDR(long ipA, long ipB); static long numberOfAddress(String cidrAddress); }
AddressUtils { public static long numberOfAddress(String cidrAddress) { SubnetInfo info = new SubnetUtils(cidrAddress).getInfo(); long lowestAddrAsLong = AddressUtils.ipv4ToLong(info.getNetworkAddress()); long highestAddrAsLong = AddressUtils.ipv4ToLong(info.getBroadcastAddress()); return (highestAddrAsLong - lowestAddrAsLong) + 1; } private  AddressUtils(); static String longToIpv4(long ipAsLong); static long ipv4ToLong(String ipAsText); static String toCIDR(long ipA, long ipB); static long numberOfAddress(String cidrAddress);  }