init commit (#11496)

This commit is contained in:
Azhwani 2021-11-28 16:47:49 +01:00 committed by GitHub
parent 8809312a13
commit 7b564fe3ef
1 changed files with 15 additions and 0 deletions

View File

@ -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));
}
} }