diff --git a/assert/assertion_format.go b/assert/assertion_format.go index a19a89279..8de83577c 100644 --- a/assert/assertion_format.go +++ b/assert/assertion_format.go @@ -691,6 +691,11 @@ func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bo // // assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") // assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -783,6 +788,11 @@ func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) bool // // assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") // assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") +// +// The rx argument may be a *regexp.Regexpf, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexpf value that is not a valid +// regular expression therefore causes a panic. func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/assert/assertion_forward.go b/assert/assertion_forward.go index cd2a86061..f7006ed10 100644 --- a/assert/assertion_forward.go +++ b/assert/assertion_forward.go @@ -1370,6 +1370,11 @@ func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{} // // a.NotRegexp(regexp.MustCompile("starts"), "it's starting") // a.NotRegexp("^start", "it's not starting") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1381,6 +1386,11 @@ func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...in // // a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") // a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1554,6 +1564,11 @@ func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) b // // a.Regexp(regexp.MustCompile("start"), "it's starting") // a.Regexp("start...$", "it's not starting") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1565,6 +1580,11 @@ func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...inter // // a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") // a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") +// +// The rx argument may be a *regexp.Regexpf, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexpf value that is not a valid +// regular expression therefore causes a panic. func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() diff --git a/assert/assertions.go b/assert/assertions.go index 1419e4776..b28d0f5c6 100644 --- a/assert/assertions.go +++ b/assert/assertions.go @@ -1730,6 +1730,11 @@ func matchRegexp(rx interface{}, str interface{}) bool { // // assert.Regexp(t, regexp.MustCompile("start"), "it's starting") // assert.Regexp(t, "start...$", "it's not starting") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1748,6 +1753,11 @@ func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface // // assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") // assert.NotRegexp(t, "^start", "it's not starting") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/require/require.go b/require/require.go index 652871f2e..71c0cc651 100644 --- a/require/require.go +++ b/require/require.go @@ -1703,6 +1703,11 @@ func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interfac // // require.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") // require.NotRegexp(t, "^start", "it's not starting") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1717,6 +1722,11 @@ func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interf // // require.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") // require.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1935,6 +1945,11 @@ func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) { // // require.Regexp(t, regexp.MustCompile("start"), "it's starting") // require.Regexp(t, "start...$", "it's not starting") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1949,6 +1964,11 @@ func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface // // require.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") // require.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") +// +// The rx argument may be a *regexp.Regexpf, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexpf value that is not a valid +// regular expression therefore causes a panic. func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/require/require_forward.go b/require/require_forward.go index edac147ef..5a70620e8 100644 --- a/require/require_forward.go +++ b/require/require_forward.go @@ -1343,6 +1343,11 @@ func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args ...inte // // a.NotRegexp(regexp.MustCompile("starts"), "it's starting") // a.NotRegexp("^start", "it's not starting") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1354,6 +1359,11 @@ func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...in // // a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") // a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1527,6 +1537,11 @@ func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) { // // a.Regexp(regexp.MustCompile("start"), "it's starting") // a.Regexp("start...$", "it's not starting") +// +// The rx argument may be a *regexp.Regexp, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexp value that is not a valid +// regular expression therefore causes a panic. func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1538,6 +1553,11 @@ func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...inter // // a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") // a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") +// +// The rx argument may be a *regexp.Regexpf, which is used directly, or any +// other value, which is converted to a string with fmt.Sprint and compiled +// with regexp.MustCompile. A non-*regexp.Regexpf value that is not a valid +// regular expression therefore causes a panic. func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper()