massert: add Err and Errf functions
This commit is contained in:
parent
d9480abb59
commit
910704ae67
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user