mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
added testcases for address#parse function,changed empty to null (conforms to existing code)
This commit is contained in:
parent
6a76b073c3
commit
68cecb168e
@ -150,7 +150,7 @@ public class Address {
|
|||||||
} catch (MimeException pe) {
|
} catch (MimeException pe) {
|
||||||
Log.e(K9.LOG_TAG, "MimeException in Address.parse()", pe);
|
Log.e(K9.LOG_TAG, "MimeException in Address.parse()", pe);
|
||||||
//but we do an silent failover : we just use the given string as name with empty address
|
//but we do an silent failover : we just use the given string as name with empty address
|
||||||
addresses.add(new Address("", addressList));
|
addresses.add(new Address(null, addressList,false));
|
||||||
}
|
}
|
||||||
return addresses.toArray(EMPTY_ADDRESS_ARRAY);
|
return addresses.toArray(EMPTY_ADDRESS_ARRAY);
|
||||||
}
|
}
|
||||||
|
37
tests/src/com/fsck/k9/helper/Address.java
Normal file
37
tests/src/com/fsck/k9/helper/Address.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.fsck.k9.helper;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class Address extends TestCase {
|
||||||
|
/**
|
||||||
|
* test the possibility to parse "From:" fields with no email.
|
||||||
|
* for example: From: News for Vector Limited - Google Finance
|
||||||
|
* http://code.google.com/p/k9mail/issues/detail?id=3814
|
||||||
|
*/
|
||||||
|
public void testParseWithMissingEmail() {
|
||||||
|
com.fsck.k9.mail.Address[] addresses = com.fsck.k9.mail.Address.parse("NAME ONLY");
|
||||||
|
assertEquals(1, addresses.length);
|
||||||
|
assertEquals(null, addresses[0].getAddress());
|
||||||
|
assertEquals("NAME ONLY", addresses[0].getPersonal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test name + valid email
|
||||||
|
*/
|
||||||
|
public void testPraseWithValidEmail() {
|
||||||
|
com.fsck.k9.mail.Address[] addresses = com.fsck.k9.mail.Address.parse("Max Mustermann <maxmuster@mann.com>");
|
||||||
|
assertEquals(1, addresses.length);
|
||||||
|
assertEquals("maxmuster@mann.com", addresses[0].getAddress());
|
||||||
|
assertEquals("Max Mustermann", addresses[0].getPersonal());
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* test with multi email addresses
|
||||||
|
*/
|
||||||
|
public void testPraseWithValidEmailMulti() {
|
||||||
|
com.fsck.k9.mail.Address[] addresses = com.fsck.k9.mail.Address.parse("lorem@ipsum.us,mark@twain.com");
|
||||||
|
assertEquals(2, addresses.length);
|
||||||
|
assertEquals("lorem@ipsum.us", addresses[0].getAddress());
|
||||||
|
assertEquals(null, addresses[0].getPersonal());
|
||||||
|
assertEquals("mark@twain.com", addresses[1].getAddress());
|
||||||
|
assertEquals(null, addresses[1].getPersonal());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user