Created
January 31, 2018 00:51
-
-
Save thieux/cede0acd8e5b37b3a26f248aac8c6f6f to your computer and use it in GitHub Desktop.
Java style regular expressions kata in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mathieupauly.regexkata; | |
import org.junit.Test; | |
import static org.assertj.core.api.Assertions.assertThat; | |
public class RegexTest { | |
@Test | |
public void selfMatching() { | |
assertThat("a".matches("a")).isEqualTo(true); | |
} | |
@Test | |
public void selfMatchingOnMulticharacters() { | |
assertThat("abc".matches("abc")).isEqualTo(true); | |
} | |
@Test | |
public void matchOr() { | |
assertThat("a".matches("a|b")).isEqualTo(true); | |
} | |
@Test | |
public void orNothing() { | |
assertThat("a".matches("a|")).isEqualTo(true); | |
assertThat("a".matches("|a")).isEqualTo(true); | |
} | |
@Test | |
public void dot() { | |
assertThat("a".matches(".")).isEqualTo(true); | |
} | |
@Test | |
public void orHasLowerPrecedenceThanSequence() { | |
assertThat("ab".matches("ab|xy")).isEqualTo(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment