@@ -85,6 +85,13 @@ func TypeOf(expect, actual interface{}) bool {
8585
8686// IsType asserts that two objects type are equal
8787func IsType (t TestingT , expect string , actual interface {}, args ... interface {}) bool {
88+ if actual == nil && expect == "nil" {
89+ return true
90+ }
91+ if actual == nil {
92+ return false
93+ }
94+
8895 s := reflect .TypeOf (actual ).String ()
8996
9097 info , call , cinfo := typeCall (expect , s , args ... )
@@ -236,6 +243,12 @@ func NotNil(t TestingT, actual interface{}, args ...interface{}) bool {
236243 return NotEqual (t , nil , actual , info , call , cinfo )
237244}
238245
246+ // Error asserts that equal error.
247+ func Error (t TestingT , actual interface {}, args ... interface {}) bool {
248+ info , call , cinfo := callAdd (Type , args ... )
249+ return IsType (t , "*errors.errorString" , actual , info , call , cinfo )
250+ }
251+
239252// Empty asserts that empty and objects are equal.
240253func Empty (t TestingT , actual interface {}, args ... interface {}) bool {
241254 info , call , cinfo := typeCall ("" , actual , args ... )
0 commit comments