### Question:
IPAddress { public IPAddress previousIPAddress() throws InvalidIPAddressException { StringTokenizer tokenizer = new StringTokenizer(ip, "."); int tokenOne = Integer.parseInt(tokenizer.nextToken()); int tokenTwo = Integer.parseInt(tokenizer.nextToken()); int tokenThree = Integer.parseInt(tokenizer.nextToken()); int tokenFour = Integer.parseInt(tokenizer.nextToken()); tokenFour = (tokenFour + 255) % 256; if (tokenFour == 255) { tokenThree = (tokenThree + 255) % 256; if (tokenThree == 255) { tokenTwo = (tokenTwo + 255) % 256; if (tokenTwo == 255) { tokenOne = (tokenOne + 255) % 256; } } } return IPAddress.newIPAddress(tokenOne + "." + tokenTwo + "." + tokenThree + "." + tokenFour); } IPAddress(); private  IPAddress(String ipAddress); static IPAddress newIPAddress(String ipAddress); @Override boolean equals(Object o); String getFirstOctet(); String getSecondOctet(); String getThirdOctet(); String getFourthOctet(); String getIp(); IPAddress nextIPAddress(); IPAddress previousIPAddress(); void setIp(String ip); @Override String toString(); Boolean isBiggerThan(IPAddress ip); static final String IPADDRESS_PATTERN; }### Answer:
@Test public void testPreviousIPAddress() throws InvalidIPAddressException { assertTrue(IPAddress.newIPAddress("0.0.0.1").previousIPAddress().toString() .equalsIgnoreCase("0.0.0.0")); assertTrue(IPAddress.newIPAddress("0.0.1.1").previousIPAddress().toString() .equalsIgnoreCase("0.0.1.0")); assertTrue(IPAddress.newIPAddress("22.33.43.56").previousIPAddress().toString() .equalsIgnoreCase("22.33.43.55")); assertTrue(IPAddress.newIPAddress("0.0.2.0").previousIPAddress().toString() .equalsIgnoreCase("0.0.1.255")); assertTrue(IPAddress.newIPAddress("0.1.0.0").previousIPAddress().toString() .equalsIgnoreCase("0.0.255.255")); assertTrue(IPAddress.newIPAddress("1.0.0.0").previousIPAddress().toString() .equalsIgnoreCase("0.255.255.255")); assertTrue(IPAddress.newIPAddress("0.255.1.0").previousIPAddress().toString() .equalsIgnoreCase("0.255.0.255")); assertTrue(IPAddress.newIPAddress("0.0.0.0").previousIPAddress().toString() .equalsIgnoreCase("255.255.255.255")); assertTrue(IPAddress.newIPAddress("0.255.0.abc").previousIPAddress().toString() .equalsIgnoreCase("")); }