massert: add Err and Errf functions

This commit is contained in:
Brian Picciano 2018-10-28 15:09:14 -04:00
parent d9480abb59
commit 910704ae67

View File

@ -282,6 +282,16 @@ func None(aa ...Assertion) Assertion {
return newAssertion(fn, fmtMultiDescr("None", aa...), 0)
}
// Err returns an Assertion which always fails with the given error.
func Err(err error) Assertion {
return newAssertion(func() error { return err }, "", 0)
}
// Errf is like Err but allows for a formatted string.
func Errf(str string, args ...interface{}) Assertion {
return Err(fmt.Errorf(str, args...))
}
////////////////////////////////////////////////////////////////////////////////
func toStr(i interface{}) string {