Be more liberal with external address formatting
A string like "bonbon" should just be "bonbon". That is apparently a valid SMS source address. // FREEBIEpull/1/head
parent
abea2d0bdf
commit
a67d0b18ff
@ -0,0 +1,50 @@
|
||||
package org.thoughtcrime.securesms.database;
|
||||
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
public class AddressTest {
|
||||
|
||||
@Before
|
||||
public void setup() {}
|
||||
|
||||
@Test
|
||||
public void testAddressString() throws Exception {
|
||||
Address.ExternalAddressFormatter formatter = new Address.ExternalAddressFormatter("+14152222222");
|
||||
assertEquals(formatter.format("bonbon"), "bonbon");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddressShortCode() throws Exception {
|
||||
Address.ExternalAddressFormatter formatter = new Address.ExternalAddressFormatter("+14152222222");
|
||||
assertEquals(formatter.format("40404"), "40404");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmailAddress() throws Exception {
|
||||
Address.ExternalAddressFormatter formatter = new Address.ExternalAddressFormatter("+14152222222");
|
||||
assertEquals(formatter.format("junk@junk.net"), "junk@junk.net");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNumberArbitrary() throws Exception {
|
||||
Address.ExternalAddressFormatter formatter = new Address.ExternalAddressFormatter("+14152222222");
|
||||
assertEquals(formatter.format("(415) 111-1122"), "+14151111122");
|
||||
assertEquals(formatter.format("(415) 111 1123"), "+14151111123");
|
||||
assertEquals(formatter.format("415-111-1124"), "+14151111124");
|
||||
assertEquals(formatter.format("415.111.1125"), "+14151111125");
|
||||
assertEquals(formatter.format("+1 415.111.1126"), "+14151111126");
|
||||
assertEquals(formatter.format("+1 415 111 1127"), "+14151111127");
|
||||
assertEquals(formatter.format("+1 (415) 111 1128"), "+14151111128");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroup() throws Exception {
|
||||
Address.ExternalAddressFormatter formatter = new Address.ExternalAddressFormatter("+14152222222");
|
||||
assertEquals(formatter.format("__textsecure_group__!foobar"), "__textsecure_group__!foobar");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue