parent
4a58fc96e6
commit
e77e8c0025
@ -11,7 +11,7 @@ public class StringContainingCharactersUnitTest {
|
|||||||
|
|
||||||
private static final Pattern[] inputRegexes = new Pattern[4];
|
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 {
|
static {
|
||||||
inputRegexes[0] = Pattern.compile(".*[A-Z].*");
|
inputRegexes[0] = Pattern.compile(".*[A-Z].*");
|
||||||
@ -101,21 +101,36 @@ public class StringContainingCharactersUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void givenSingleRegex_whenMatchingCorrectString_thenMatches() {
|
public void givenSingleRegex_whenMatchingCorrectString_thenMatches() {
|
||||||
String validInput = "Ab3;";
|
String validInput = "Ab3;";
|
||||||
assertTrue(Pattern.compile(regex).matcher(validInput).matches());
|
assertTrue(Pattern
|
||||||
|
.compile(regex)
|
||||||
|
.matcher(validInput)
|
||||||
|
.matches());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenSingleRegex_whenMatchingWrongStrings_thenNotMatching() {
|
public void givenSingleRegex_whenMatchingWrongStrings_thenNotMatching() {
|
||||||
String invalidInput = "Ab3";
|
String invalidInput = "Ab3";
|
||||||
assertFalse(Pattern.compile(regex).matcher(invalidInput).matches());
|
assertFalse(Pattern
|
||||||
|
.compile(regex)
|
||||||
|
.matcher(invalidInput)
|
||||||
|
.matches());
|
||||||
|
|
||||||
invalidInput = "Ab;";
|
invalidInput = "Ab;";
|
||||||
assertFalse(Pattern.compile(regex).matcher(invalidInput).matches());
|
assertFalse(Pattern
|
||||||
|
.compile(regex)
|
||||||
|
.matcher(invalidInput)
|
||||||
|
.matches());
|
||||||
|
|
||||||
invalidInput = "A3;";
|
invalidInput = "A3;";
|
||||||
assertFalse(Pattern.compile(regex).matcher(invalidInput).matches());
|
assertFalse(Pattern
|
||||||
|
.compile(regex)
|
||||||
|
.matcher(invalidInput)
|
||||||
|
.matches());
|
||||||
|
|
||||||
invalidInput = "b3;";
|
invalidInput = "b3;";
|
||||||
assertFalse(Pattern.compile(regex).matcher(invalidInput).matches());
|
assertFalse(Pattern
|
||||||
|
.compile(regex)
|
||||||
|
.matcher(invalidInput)
|
||||||
|
.matches());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user