Skip to content

Commit

Permalink
Catch partial regexes in test cases
Browse files Browse the repository at this point in the history
Old test cases only matched regex in test string, so would accept regexes such as """\d{2} $month \d{3}""" or even """$month""".
  • Loading branch information
jxilt authored Oct 18, 2016
1 parent 3463c54 commit 30a750c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import java.util.regex.Pattern

class _05_String_Templates() {
@Test fun match() {
assertTrue(Pattern.compile(task5()).matcher("Douglas Adams (11 MAR 1952)").find())
assertTrue("11 MAR 1952".matches(task5().toRegex()))
}

@Test fun match1() {
assertTrue(Pattern.compile(task5()).matcher("Stephen Fry (24 AUG 1957)").find())
assertTrue("24 AUG 1957".matches(task5().toRegex()))
}

@Test fun doNotMatch() {
assertFalse(Pattern.compile(task5()).matcher("Stephen Fry (24 RRR 1957)").find())
assertFalse("24 RRR 1957".matches(task5().toRegex()))
}
}
}

0 comments on commit 30a750c

Please sign in to comment.