Skip to content

Instantly share code, notes, and snippets.

@artkoshelev
Created July 2, 2013 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artkoshelev/5907938 to your computer and use it in GitHub Desktop.
Save artkoshelev/5907938 to your computer and use it in GitHub Desktop.
package org.junit.tests.running.classes;
import static org.cthul.matchers.CthulMatchers.matchesPattern;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import static org.hamcrest.MatcherAssert.assertThat;
@RunWith(Parameterized.class)
public class EmailRegexpTest {
private static final String EMAIL_REGEXP = "^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})$";
@Parameter(0)
public String email;
@Parameters
public static Collection<Object[]> data() {
List<Object[]> data = new ArrayList<Object[]>() {{
add(new Object[]{"art.koshelev@gmail.com"});
add(new Object[]{"mail@stefan-birkner.de"});
}};
return data;
}
@Test
public void positiveTest() {
assertThat(email, matchesPattern(EMAIL_REGEXP));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment