Created
January 25, 2011 20:35
-
-
Save webdevwilson/795600 to your computer and use it in GitHub Desktop.
Regular Expression Matcher for Unit testing
This file contains 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
public class RegexMatcher extends BaseMatcher{ | |
private final String regex; | |
public RegexMatcher(String regex){ | |
this.regex = regex; | |
} | |
public boolean matches(Object o){ | |
return ((String)o).matches(regex); | |
} | |
public void describeTo(Description description){ | |
description.appendText("matches regex="); | |
} | |
public static RegexMatcher matches(String regex){ | |
return new RegexMatcher(regex); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment