### Question:
Ip4 implements Host { @Nullable static Ip4 parse(String hostname) { String[] segments = hostname.split("\\."); if (segments.length != 4) { return null; } byte[] addr = new byte[4]; for (int i = 0; i < segments.length; i++) { int val; String segment = segments[i]; if (segment.length() > 1 && segment.startsWith("0")) { return null; } try { val = Integer.parseInt(segment); } catch (NumberFormatException e) { return null; } if (val < 0 || val > 255) { return null; } addr[i] = (byte) val; } return fromAddress(addr); }    }### Answer:
@Test public void removeTrailingPeriod() { assertEquals("255.255.255.255", Hosts.parse("255.255.255.255.").name()); }
@Test public void percentDecodeBeforeParsing() { assertEquals("1.1.1.1", Hosts.parse("%31.%31.%31.%31").name()); assertEquals("1.1.1.1", Hosts.parse("1%2e1%2e1%2e1").name()); }
@Test public void disambiguateUnicodeFirst() { assertEquals("1.1.1.1", Hosts.parse("１。１。１。１").name()); }
@Test public void ipv4() { assertEquals("1.1.1.1", Hosts.parse("1.1.1.1").name()); assertEquals("0.0.0.1", Hosts.parse("0.0.0.1").name()); assertEquals("0.0.0.0", Hosts.parse("0.0.0.0").name()); assertEquals("255.255.255.255", Hosts.parse("255.255.255.255").name()); }