MCPcopy Index your code
hub / github.com/expr-lang/expr / TestRegexp

Function TestRegexp

internal/testify/assert/assertions_test.go:1967–1999  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1965}
1966
1967func 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
2001func testAutogeneratedFunction() {
2002 defer func() {

Callers

nothing calls this directly

Calls 4

TrueFunction · 0.70
RegexpFunction · 0.70
FalseFunction · 0.70
NotRegexpFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…