init commit (#11496)
This commit is contained in:
parent
8809312a13
commit
7b564fe3ef
|
@ -11,6 +11,9 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class MatcherUnitTest {
|
public class MatcherUnitTest {
|
||||||
|
|
||||||
|
private static final String STRING_INPUT = "test+";
|
||||||
|
private static final String REGEX = "\\+";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenFindFourDigitWorks_thenCorrect() {
|
public void whenFindFourDigitWorks_thenCorrect() {
|
||||||
Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d");
|
Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d");
|
||||||
|
@ -60,4 +63,16 @@ public class MatcherUnitTest {
|
||||||
assertTrue(m.matches());// matches will always return the same return
|
assertTrue(m.matches());// matches will always return the same return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenUsingMatcher_thenReturnTrue() {
|
||||||
|
Pattern pattern = Pattern.compile(REGEX);
|
||||||
|
Matcher matcher = pattern.matcher(STRING_INPUT);
|
||||||
|
assertTrue(matcher.find());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenUsingMatches_thenReturnFalse() {
|
||||||
|
assertFalse(Pattern.matches(REGEX, STRING_INPUT));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue