| 1965 | } |
| 1966 | |
| 1967 | func TestRegexp(t *testing.T) { |
| 1968 | mockT := new(testing.T) |
| 1969 | |
| 1970 | cases := []struct { |
| 1971 | rx, str string |
| 1972 | }{ |
| 1973 | {"^start", "start of the line"}, |
| 1974 | {"end$", "in the end"}, |
| 1975 | {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12.34"}, |
| 1976 | } |
| 1977 | |
| 1978 | for _, tc := range cases { |
| 1979 | True(t, Regexp(mockT, tc.rx, tc.str)) |
| 1980 | True(t, Regexp(mockT, regexp.MustCompile(tc.rx), tc.str)) |
| 1981 | False(t, NotRegexp(mockT, tc.rx, tc.str)) |
| 1982 | False(t, NotRegexp(mockT, regexp.MustCompile(tc.rx), tc.str)) |
| 1983 | } |
| 1984 | |
| 1985 | cases = []struct { |
| 1986 | rx, str string |
| 1987 | }{ |
| 1988 | {"^asdfastart", "Not the start of the line"}, |
| 1989 | {"end$", "in the end."}, |
| 1990 | {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12a.34"}, |
| 1991 | } |
| 1992 | |
| 1993 | for _, tc := range cases { |
| 1994 | False(t, Regexp(mockT, tc.rx, tc.str), "Expected \"%s\" to not match \"%s\"", tc.rx, tc.str) |
| 1995 | False(t, Regexp(mockT, regexp.MustCompile(tc.rx), tc.str)) |
| 1996 | True(t, NotRegexp(mockT, tc.rx, tc.str)) |
| 1997 | True(t, NotRegexp(mockT, regexp.MustCompile(tc.rx), tc.str)) |
| 1998 | } |
| 1999 | } |
| 2000 | |
| 2001 | func testAutogeneratedFunction() { |
| 2002 | defer func() { |