MCPcopy Index your code
hub / github.com/go-errors/errors / TestIs113

Function TestIs113

error_1_13_test.go:11–54  ·  view source on GitHub ↗

This test should work only for go 1.13 and latter

(t *testing.T)

Source from the content-addressed store, hash-verified

9
10// This test should work only for go 1.13 and latter
11func TestIs113(t *testing.T) {
12 custErr := errorWithCustomIs{
13 Key: "TestForFun",
14 Err: io.EOF,
15 }
16
17 shouldMatch := errorWithCustomIs{
18 Key: "TestForFun",
19 }
20
21 shouldNotMatch := errorWithCustomIs{Key: "notOk"}
22
23 if !Is(custErr, shouldMatch) {
24 t.Errorf("custErr is not a TestForFun customError")
25 }
26
27 if Is(custErr, shouldNotMatch) {
28 t.Errorf("custErr is a notOk customError")
29 }
30
31 if !Is(custErr, New(shouldMatch)) {
32 t.Errorf("custErr is not a New(TestForFun customError)")
33 }
34
35 if Is(custErr, New(shouldNotMatch)) {
36 t.Errorf("custErr is a New(notOk customError)")
37 }
38
39 if !Is(New(custErr), shouldMatch) {
40 t.Errorf("New(custErr) is not a TestForFun customError")
41 }
42
43 if Is(New(custErr), shouldNotMatch) {
44 t.Errorf("New(custErr) is a notOk customError")
45 }
46
47 if !Is(New(custErr), New(shouldMatch)) {
48 t.Errorf("New(custErr) is not a New(TestForFun customError)")
49 }
50
51 if Is(New(custErr), New(shouldNotMatch)) {
52 t.Errorf("New(custErr) is a New(notOk customError)")
53 }
54}
55
56type errorWithCustomIs struct {
57 Key string

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
IsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…