Fix phone number format crash.

This commit is contained in:
Cody Henthorne
2021-12-20 12:34:40 -05:00
committed by Greyson Parrelli
parent a17fd447a7
commit 8c34357cc6
3 changed files with 33 additions and 9 deletions

View File

@@ -3,13 +3,17 @@ package org.thoughtcrime.securesms.phonenumbers;
import org.junit.Before;
import org.junit.Test;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.testutil.EmptyLogger;
import static junit.framework.Assert.assertEquals;
public class PhoneNumberFormatterTest {
@Before
public void setup() {}
public void setup() {
Log.initialize(new EmptyLogger());
}
@Test
public void testAddressString() throws Exception {
@@ -89,4 +93,11 @@ public class PhoneNumberFormatterTest {
PhoneNumberFormatter formatter = new PhoneNumberFormatter("US", true);
assertEquals(formatter.format("(415) 111-1122"), "+14151111122");
}
@Test
public void testParseNumberFailWithoutLocalNumber() {
PhoneNumberFormatter formatter = new PhoneNumberFormatter("US", true);
assertEquals("+144444444441234512312312312312312312312", formatter.format("44444444441234512312312312312312312312"));
assertEquals("+144444444441234512312312312312312312312", formatter.format("144444444441234512312312312312312312312"));
}
}