MCPcopy
hub / github.com/silenceper/wechat / TestDecodeWithError

Function TestDecodeWithError

util/error_test.go:35–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

33}
34
35func TestDecodeWithError(t *testing.T) {
36 type DE struct {
37 CommonError
38 }
39 var obj DE
40 err := DecodeWithError([]byte(errData), &obj, "Send")
41 if err == nil {
42 t.Error("DecodeWithError should return error")
43 return
44 }
45
46 cErr, ok := err.(*CommonError)
47 if !ok {
48 t.Errorf("DecodeWithError should return *CommonError but %T", err)
49 return
50 }
51 if !(cErr.ErrCode == 43101 && cErr.ErrMsg == "user refuse to accept the msg" && cErr.Error() == expectError) {
52 t.Error("DecodeWithError return bad *CommonError")
53 return
54 }
55}

Callers

nothing calls this directly

Calls 2

DecodeWithErrorFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…