MCPcopy Create free account
hub / github.com/go-dev-frame/sponge / TestEncodingError

Function TestEncodingError

pkg/encoding/encoding_test.go:52–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestEncodingError(t *testing.T) {
53 gobE := GobEncoding{}
54 // gob error test
55 err := gobE.Unmarshal([]byte("foo"), nil)
56 assert.Error(t, err)
57
58 jsonE := JSONEncoding{}
59 // json error test
60 err = jsonE.Unmarshal([]byte("foo"), nil)
61 assert.Error(t, err)
62
63 jsonDE := JSONGzipEncoding{}
64 // gzip error test
65 _, err = jsonDE.Marshal(make(chan string))
66 assert.Error(t, err)
67 err = jsonDE.Unmarshal([]byte("foo"), nil)
68 assert.Error(t, err)
69 data, _ := GzipEncode([]byte("foo"))
70 err = jsonDE.Unmarshal(data, make(chan string))
71 assert.Error(t, err)
72 _, err = GzipDecode(nil)
73 assert.Error(t, err)
74
75 jsonSE := JSONSnappyEncoding{}
76 // snappy error test
77 _, err = jsonSE.Marshal(make(chan string))
78 assert.Error(t, err)
79 err = jsonSE.Unmarshal([]byte("foo"), nil)
80 assert.Error(t, err)
81
82 msgE := MsgPackEncoding{}
83 // pack error test
84 err = msgE.Unmarshal([]byte("foo"), nil)
85 assert.Error(t, err)
86}
87
88type codec struct{}
89

Callers

nothing calls this directly

Calls 10

UnmarshalMethod · 0.95
UnmarshalMethod · 0.95
MarshalMethod · 0.95
UnmarshalMethod · 0.95
MarshalMethod · 0.95
UnmarshalMethod · 0.95
UnmarshalMethod · 0.95
GzipEncodeFunction · 0.85
GzipDecodeFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected