package br.com.six2six.fixturefactory.function;

import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;

import org.junit.Test;

import br.com.six2six.fixturefactory.function.impl.RegexFunction;

public class RegexFunctionTest {

	@Test
	public void regexString() {
		String pattern = "\\w{8}";
		String value = new RegexFunction(pattern).generateValue();
		assertNotNull("Generated string can not be null", value);
		assertTrue(String.format("Generated string no match with %s", pattern), value.matches(pattern));
	}
	
	@Test
	public void regexNumber() {
		String pattern = "\\d{3,8}";
		String value = new RegexFunction(pattern).generateValue();
		assertNotNull("Generated number can not be null", value);
		assertTrue(String.format("Generated number no match with %s", pattern), value.matches(pattern));
	}

	@Test
	public void regexPhoneNumber() {
		String pattern = "(\\d{2})-(\\d{4})-(\\d{4})";
		String value = new RegexFunction(pattern).generateValue();
		assertNotNull("Generated phone number can not be null", value);
		assertTrue(String.format("Generated phone number no match with %s", pattern), value.matches(pattern));
	}
	
}

@@ -238,618 +238,663 @@
 on;%0A
-%0Apublic class RegexFunctionTest %7B%0A%0A%09@Test%0A%09public void regexString() %7B%0A%09%09String pattern = %22%5C%5Cw%7B8%7D%22;%0A%09%09String value = new RegexFunction(pattern).generateValue();%0A%09%09assertNotNull(%22Generated string can not be null%22, value);%0A%09%09assertTrue(String.format(%22Generated string no match with %25s%22, pattern), value.matches(pattern));%0A%09%7D%0A%09%0A%09@Test%0A%09public void regexNumber() %7B%0A%09%09String pattern = %22%5C%5Cd%7B3,8%7D%22;%0A%09%09String value = new RegexFunction(pattern).generateValue();%0A%09%09assertNotNull(%22Generated number can not be null%22, value);%0A%09%09assertTrue(String.format(%22Generated number no match with %25s%22, pattern), value.matches(
+import org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized;%0Aimport org.junit.runners.Parameterized.Parameters;%0A%0Aimport java.util.Arrays;%0A%0A@RunWith(Parameterized.class)%0Apublic class RegexFunctionTest %7B%0A%0A%09@Parameters(name= %22%7Bindex%7D: regex %7B0%7D=%7B1%7D%22)%0A%09public static Iterable%3CString%5B%5D%3E data() %7B%0A%09%09return Arrays.asList(new String%5B%5D%5B%5D%7B%0A%09%09%09%09%7B%22String%22, %22%5C%5Cw%7B8%7D%22%7D,%0A%09%09%09%09%7B%22Number%22, %22%5C%5Cd%7B3,8%7D%22%7D,%0A%09%09%09%09%7B%22Phone number%22, %22(%5C%5Cd%7B2%7D)-(%5C%5Cd%7B4%7D)-(%5C%5Cd%7B4%7D)%22%7D,%0A%09%09%09%09%7B%22MD5%22, %22%5B0-9a-f%5D%7B32%7D%22%7D%0A%09%09%7D);%0A%09%7D%0A%0A%09private String regexName;%0A%09private String pattern;%0A%0A%09public RegexFunctionTest(String regexName, String pattern) %7B%0A%09%09this.regexName = regexName;%0A%09%09this.pattern = 
 pattern
-))
 ;%0A%09%7D
@@ -919,77 +919,28 @@
 oid 
-regexPhoneNumber() %7B%0A%09%09String pattern = %22(%5C%5Cd%7B2%7D)-(%5C%5Cd%7B4%7D)-(%5C%5Cd%7B4%7D)%22;
+testAgainstRegex() %7B
 %0A%09%09S
@@ -1017,54 +1017,74 @@
 ull(
-%22Generated phone number can not be null%22, valu
+String.format(%22Generated %25s can not be null%22, regexName), regexNam
 e);%0A
@@ -1125,20 +1125,15 @@
 ted 
-phone number
+%25s (%25s)
  no 
@@ -1147,16 +1147,34 @@
 ith %25s%22,
+ regexName, value,
  pattern

Test for character range regex introduced in bfgex 1.1.1