mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 01:18:20 +01:00
Add a utility method for testing if a number begins with a decimal prefix
This commit is contained in:
committed by
ravi-signal
parent
7201938793
commit
96fb0ac3ae
@@ -5,16 +5,15 @@
|
||||
|
||||
package org.whispersystems.textsecuregcm.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class UtilTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@@ -39,4 +38,15 @@ class UtilTest {
|
||||
Arguments.of(oldFormatBeninE164, List.of(oldFormatBeninE164, newFormatBeninE164))
|
||||
);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"0, 1, false",
|
||||
"123456789, 1, true",
|
||||
"123456789, 123, true",
|
||||
"123456789, 456, false",
|
||||
})
|
||||
void startsWithDecimal(final long number, final long prefix, final boolean expectStartsWithPrefix) {
|
||||
assertEquals(expectStartsWithPrefix, Util.startsWithDecimal(number, prefix));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user