MCPcopy
hub / github.com/stretchr/testify / Regexp

Function Regexp

assert/assertions.go:1726–1738  ·  assert/assertions.go::Regexp

Regexp asserts that a specified regexp matches a string. assert.Regexp(t, regexp.MustCompile("start"), "it's starting") assert.Regexp(t, "start...$", "it's not starting")

(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1724// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
1725// assert.Regexp(t, "start...$", "it's not starting")
1726func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
1727 if h, ok := t.(tHelper); ok {
1728 h.Helper()
1729 }
1730
1731 match := matchRegexp(rx, str)
1732
1733 if !match {
1734 Fail(t, fmt.Sprintf("Expect \"%v\" to match \"%v\"", str, rx), msgAndArgs...)
1735 }
1736
1737 return match
1738}
1739
1740// NotRegexp asserts that a specified regexp does not match a string.
1741//

Calls 3

matchRegexpFunction · 0.85
FailFunction · 0.70
HelperMethod · 0.65