/** * Tests that: 1. firstAddress() with empty list returns null. 2. firstAddress() with non-empty * returns the same as fromHeader()[0] */ public void testFirstAddress() { assertNull(Address.firstAddress(null)); assertNull(Address.firstAddress("")); for (Address[] list : TO_HEADER_CASES) { String packed = Address.toHeader(list); Address[] array = Address.fromHeader(packed); Address first = Address.firstAddress(packed); assertTrue(packed, addressEquals(array[0], first)); } }
/** Tests that fromHeaderToString() returns the same result as toString(fromHeader()). */ public void testFromHeaderToString() { assertNull(Address.fromHeaderToString(null)); assertNull(Address.fromHeaderToString("")); for (Address[] list : TO_HEADER_CASES) { String packed = Address.toHeader(list); String s1 = Address.fromHeaderToString(packed); String s2 = Address.toString(Address.fromHeader(packed)); assertEquals(s2, s2, s1); } }
/** * Simple quick checks of empty-input edge conditions for fromHeader() * * <p>NOTE: This is not a claim that these edge cases are "correct", only to maintain consistent * behavior while I am changing some of the code in the function under test. */ public void testEmptyFromHeader() { Address[] result; /* // null input => empty array result = Address.fromHeader(null); assertTrue("unpacking null address", result != null && result.length == 0); */ // empty string input => empty array result = Address.fromHeader(""); assertTrue("unpacking zero-length", result != null && result.length == 0); }
public void testToHeaderFromHeader() { for (Address[] list : TO_HEADER_CASES) { String packed = Address.toHeader(list); assertTrue(packed, addressArrayEquals(list, Address.fromHeader(packed))); } }