Bael 2139 update (#5037)

* code formatted

* Regex optimized.
This commit is contained in:
cdjole 2018-08-22 23:31:47 +02:00 committed by maibin
parent 4a58fc96e6
commit e77e8c0025

View File

@ -11,7 +11,7 @@ public class StringContainingCharactersUnitTest {
private static final Pattern[] inputRegexes = new Pattern[4];
private static final String regex = "^(?=.*?\\p{Lu})(?=.*?[\\p{L}&&[^\\p{Lu}]])(?=.*?\\d)" + "(?=.*?[`~!@#$%^&*()\\-_=+\\\\\\|\\[{\\]};:'\",<.>/?]).*$";
private static final String regex = "^(?=.*?\\p{Lu})(?=.*?\\p{Ll})(?=.*?\\d)(?=.*?[`~!@#$%^&*()\\-_=+\\\\|\\[{\\]};:'\",<.>/?]).*$";
static {
inputRegexes[0] = Pattern.compile(".*[A-Z].*");
@ -101,21 +101,36 @@ public class StringContainingCharactersUnitTest {
@Test
public void givenSingleRegex_whenMatchingCorrectString_thenMatches() {
String validInput = "Ab3;";
assertTrue(Pattern.compile(regex).matcher(validInput).matches());
assertTrue(Pattern
.compile(regex)
.matcher(validInput)
.matches());
}
@Test
public void givenSingleRegex_whenMatchingWrongStrings_thenNotMatching() {
String invalidInput = "Ab3";
assertFalse(Pattern.compile(regex).matcher(invalidInput).matches());
assertFalse(Pattern
.compile(regex)
.matcher(invalidInput)
.matches());
invalidInput = "Ab;";
assertFalse(Pattern.compile(regex).matcher(invalidInput).matches());
assertFalse(Pattern
.compile(regex)
.matcher(invalidInput)
.matches());
invalidInput = "A3;";
assertFalse(Pattern.compile(regex).matcher(invalidInput).matches());
assertFalse(Pattern
.compile(regex)
.matcher(invalidInput)
.matches());
invalidInput = "b3;";
assertFalse(Pattern.compile(regex).matcher(invalidInput).matches());
assertFalse(Pattern
.compile(regex)
.matcher(invalidInput)
.matches());
}
}