The EmailValidator class has the isValidEmail () function, which produces a true answer when email addresses are valid and false if invalid. To test the accuracy of this function, you are asked to produce 7 different test functions. These test functions are as follows; The correct e-mail address, subdomain e-mail address .com-free e-mail address, invalid e-mail address, e-mail address without user name, blank entry and null value entries must be present.
public class EmailValidator{
public static final Pattern EMAIL_PATTERN = Pattern.compile(
"[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}"+"\\@"+
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}"+"("+"\\."+
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}"+")+");
public static boolean isValidEmail(CharSequence email){
return email != null &&;
EMAIL_PATTERN.matcher(email).matches();
}
}
Aucun commentaire:
Enregistrer un commentaire