Java Assert assertMatches(String name, String regExp, String actual)

Here you can find the source of assertMatches(String name, String regExp, String actual)

Description

assert Matches

License

Apache License

Declaration

public static void assertMatches(String name, String regExp, String actual) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static void assertMatches(String name, String regExp, String actual) {
        if (notMatches(regExp, actual)) {
            throw new AssertionError(name + ": " + actual + " is not matching " + regExp + "!");
        }// ww  w  . ja v a 2 s .  c o m
    }

    public static boolean notMatches(String regularExpression, String text) {
        if (text == null || regularExpression == null) {
            return true;
        }
        return !text.matches(regularExpression);
    }

    public static boolean matches(String regularExpression, String text) {
        if (text == null || regularExpression == null) {
            return false;
        }
        return text.matches(regularExpression);
    }
}

Related

  1. assertIsProperlyQuoted(String header, String tag)
  2. assertIsReady()
  3. assertLegal(Object underAssertion, String message)
  4. assertLongPositive(long val, String name)
  5. assertMandatoryParameter(boolean assertion, String parameterName)
  6. assertMergeTestPostcondition(double[] arr, long[] brr, int arrLen)
  7. assertMessageEquals(Throwable ex, String msg)
  8. assertNonEmpty(String s, String name)
  9. assertNonFatal(boolean test, String msg)