[BAEL-3944] Minor changes on examples and identations
This commit is contained in:
parent
a73fb8483a
commit
23bc2db643
|
@ -15,37 +15,38 @@ public class PhoneNumbersRegexUnitTest {
|
||||||
Matcher matcher = pattern.matcher("2055550125");
|
Matcher matcher = pattern.matcher("2055550125");
|
||||||
assertTrue(matcher.matches());
|
assertTrue(matcher.matches());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenMatchesTenDigitsNumberWhitespacesHyphen_thenCorrect() {
|
public void whenMatchesTenDigitsNumberWhitespacesDotHyphen_thenCorrect() {
|
||||||
Pattern pattern = Pattern.compile("^(\\d{3}[- ]?){2}\\d{4}$");
|
Pattern pattern = Pattern.compile("^(\\d{3}[- .]?){2}\\d{4}$");
|
||||||
Matcher matcher = pattern.matcher("202 555 0125");
|
Matcher matcher = pattern.matcher("202 555 0125");
|
||||||
assertTrue(matcher.matches());
|
assertTrue(matcher.matches());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenMatchesTenDigitsNumberParenthesis_thenCorrect() {
|
public void whenMatchesTenDigitsNumberParenthesis_thenCorrect() {
|
||||||
Pattern pattern = Pattern.compile("^\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$");
|
Pattern pattern = Pattern.compile("^((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$");
|
||||||
Matcher matcher = pattern.matcher("(202)-555-0125");
|
Matcher matcher = pattern.matcher("(202) 555-0125");
|
||||||
assertTrue(matcher.matches());
|
assertTrue(matcher.matches());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenMatchesTenDigitsNumberPrefix_thenCorrect() {
|
public void whenMatchesTenDigitsNumberPrefix_thenCorrect() {
|
||||||
Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$");
|
Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$");
|
||||||
Matcher matcher = pattern.matcher("+111 (202)-555-0125");
|
Matcher matcher = pattern.matcher("+111 (202) 555-0125");
|
||||||
assertTrue(matcher.matches());
|
assertTrue(matcher.matches());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenMatchesPhoneNumber_thenCorrect() {
|
public void whenMatchesPhoneNumber_thenCorrect() {
|
||||||
String patterns = "^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$" +
|
String patterns
|
||||||
"|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?){2}\\d{3}$" +
|
= "^(\\+\\d{1,3}( )?)?((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$"
|
||||||
"|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?)(\\d{2}[ ]?){2}\\d{2}$";
|
+ "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?){2}\\d{3}$"
|
||||||
|
+ "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?)(\\d{2}[ ]?){2}\\d{2}$";
|
||||||
String[] validPhoneNumbers = {"2055550125","202 555 0125", "(202)-555-0125", "+111 (202)-555-0125",
|
|
||||||
"636 856 789", "+111 636 856 789", "636 85 67 89", "+111 636 85 67 89"};
|
String[] validPhoneNumbers
|
||||||
|
= {"2055550125","202 555 0125", "(202) 555-0125", "+111 (202) 555-0125", "636 856 789", "+111 636 856 789", "636 85 67 89", "+111 636 85 67 89"};
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile(patterns);
|
Pattern pattern = Pattern.compile(patterns);
|
||||||
for(String phoneNumber : validPhoneNumbers) {
|
for(String phoneNumber : validPhoneNumbers) {
|
||||||
Matcher matcher = pattern.matcher(phoneNumber);
|
Matcher matcher = pattern.matcher(phoneNumber);
|
||||||
|
|
Loading…
Reference in New Issue