MCPcopy Create free account
hub / github.com/google/gapid / ExampleErrors

Function ExampleErrors

core/assert/error_test.go:24–53  ·  view source on GitHub ↗

An example of testing errors

()

Source from the content-addressed store, hash-verified

22
23// An example of testing errors
24func ExampleErrors() {
25 assert := assert.To(nil)
26 err := errors.New("failure")
27 otherErr := errors.New("other failure")
28 assert.For("nil succeeded").ThatError(nil).Succeeded()
29 assert.For("nil failed").ThatError(nil).Failed()
30 assert.For("err succeeded").ThatError(err).Succeeded()
31 assert.For("err failed").ThatError(err).Failed()
32 assert.For("err equals").ThatError(err).Equals(err)
33 assert.For("err not equals").ThatError(err).Equals(otherErr)
34 assert.For("err deep equals").ThatError(err).DeepEquals(err)
35 assert.For("err deep not equals").ThatError(err).DeepEquals(otherErr)
36 assert.For("message").ThatError(err).HasMessage(err.Error())
37 assert.For("wrong message").ThatError(err).HasMessage(otherErr.Error())
38 // Output:
39 // Error:nil failed
40 // Expect failure
41 // Error:err succeeded
42 // Got `failure`
43 // Expect success
44 // Error:err not equals
45 // Got `failure`
46 // Expect == `other failure`
47 // Error:err deep not equals
48 // Got `failure`
49 // Expect deep == `other failure`
50 // Error:wrong message
51 // Got `failure`
52 // Expect has message `other failure`
53}

Callers

nothing calls this directly

Calls 9

SucceededMethod · 0.80
ThatErrorMethod · 0.80
ForMethod · 0.80
FailedMethod · 0.80
HasMessageMethod · 0.80
NewMethod · 0.65
EqualsMethod · 0.65
ErrorMethod · 0.65
DeepEqualsMethod · 0.45

Tested by

no test coverage detected