Loading k9mail-library/src/main/java/com/fsck/k9/mail/Address.java +4 −1 Original line number Diff line number Diff line Loading @@ -173,7 +173,10 @@ public class Address implements Serializable { @Override public int hashCode() { int hash = mAddress.hashCode(); int hash = 0; if (mAddress != null) { hash += mAddress.hashCode(); } if (mPersonal != null) { hash += 3 * mPersonal.hashCode(); } Loading k9mail-library/src/test/java/com/fsck/k9/mail/AddressTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @RunWith(RobolectricTestRunner.class) Loading Loading @@ -89,4 +90,20 @@ public class AddressTest { assertEquals("\"sa\"mp\"le\"", Address.quoteString("\"sa\"mp\"le\"")); assertEquals("\"\"\"", Address.quoteString("\"")); } @Test public void hashCode_withoutAddress() throws Exception { Address address = Address.parse("name only")[0]; assertNull(address.getAddress()); address.hashCode(); } @Test public void hashCode_withoutPersonal() throws Exception { Address address = Address.parse("alice@example.org")[0]; assertNull(address.getPersonal()); address.hashCode(); } } Loading
k9mail-library/src/main/java/com/fsck/k9/mail/Address.java +4 −1 Original line number Diff line number Diff line Loading @@ -173,7 +173,10 @@ public class Address implements Serializable { @Override public int hashCode() { int hash = mAddress.hashCode(); int hash = 0; if (mAddress != null) { hash += mAddress.hashCode(); } if (mPersonal != null) { hash += 3 * mPersonal.hashCode(); } Loading
k9mail-library/src/test/java/com/fsck/k9/mail/AddressTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @RunWith(RobolectricTestRunner.class) Loading Loading @@ -89,4 +90,20 @@ public class AddressTest { assertEquals("\"sa\"mp\"le\"", Address.quoteString("\"sa\"mp\"le\"")); assertEquals("\"\"\"", Address.quoteString("\"")); } @Test public void hashCode_withoutAddress() throws Exception { Address address = Address.parse("name only")[0]; assertNull(address.getAddress()); address.hashCode(); } @Test public void hashCode_withoutPersonal() throws Exception { Address address = Address.parse("alice@example.org")[0]; assertNull(address.getPersonal()); address.hashCode(); } }