Skip to content

Commit

Permalink
Add couple of cases for RegExp test class
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-punko committed Oct 8, 2024
1 parent 2f99a38 commit 66b088e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/java/by/andd3dfx/regexp/RegExpCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
*/
public class RegExpCheckerTest {

@Test
public void ipAddressRegExp() {
assertThat(extractStringByRegExp("((\\d{1,2}|1\\d{2}|2[0-5]{2})\\.){3}((\\d{1,2}|1\\d{2}|2[0-5]{2}))",
"Bla, some ip-address 192.168.1.1 here."), is("192.168.1.1"));
}

@Test
public void repeatableExpressions() {
assertThat("Color should be found",
Expand Down Expand Up @@ -56,6 +62,13 @@ public void lookForwardAndBackward() {
is("30"));
}

@Test
public void reuseAlreadyDeclaredExpressionWithLinkAndLookForwardAndBackward() {
assertThat("Inner content of tag <h1> should be found",
extractStringByRegExp("(?<=<([hH][1-6])>).*(?=</\\1>)", "Bla, some <h1>test string</h1> here."),
is("test string"));
}

@Test
public void compositeExpression() {
assertThat("Phone in +ddd-dd-ddd-dd-dd format should be found",
Expand Down

0 comments on commit 66b088e

Please sign in to comment.