コード例 #1
0
 /**
  * Verifies that the actual {@code CharSequence} matches the given regular expression pattern.
  *
  * <p>Example :
  *
  * <pre>
  * // assertion will pass
  * assertThat(&quot;Frodo&quot;).matches(Pattern.compile(&quot;..o.o&quot;));
  *
  * // assertion will fail
  * assertThat(&quot;Frodo&quot;).matches(Pattern.compile(&quot;.*d&quot;));
  * </pre>
  *
  * @param pattern the regular expression to which the actual {@code CharSequence} is to be
  *     matched.
  * @return {@code this} assertion object.
  * @throws NullPointerException if the given pattern is {@code null}.
  * @throws AssertionError if the actual {@code CharSequence} is {@code null}.
  * @throws AssertionError if the actual {@code CharSequence} does not match the given regular
  *     expression.
  */
 public S matches(Pattern pattern) {
   strings.assertMatches(info, actual, pattern);
   return myself;
 }
コード例 #2
0
 /**
  * Verifies that the actual {@code CharSequence} matches the given regular expression.
  *
  * <p>Example :
  *
  * <pre>
  * // assertion will pass
  * assertThat(&quot;Frodo&quot;).matches(&quot;..o.o&quot;);
  *
  * // assertion will fail
  * assertThat(&quot;Frodo&quot;).matches(&quot;.*d&quot;);
  * </pre>
  *
  * @param regex the regular expression to which the actual {@code CharSequence} is to be matched.
  * @return {@code this} assertion object.
  * @throws NullPointerException if the given pattern is {@code null}.
  * @throws PatternSyntaxException if the regular expression's syntax is invalid.
  * @throws AssertionError if the actual {@code CharSequence} is {@code null}.
  * @throws AssertionError if the actual {@code CharSequence} does not match the given regular
  *     expression.
  */
 public S matches(CharSequence regex) {
   strings.assertMatches(info, actual, regex);
   return myself;
 }