MCPcopy
hub / github.com/gofiber/fiber / Test_item_Decode_Truncated

Function Test_item_Decode_Truncated

middleware/cache/coverage_test.go:99–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

97}
98
99func Test_item_Decode_Truncated(t *testing.T) {
100 t.Parallel()
101
102 v := populatedItem()
103 full, err := v.MarshalMsg(nil)
104 require.NoError(t, err)
105
106 for i := range len(full) {
107 prefix := full[:i]
108
109 var out item
110 _, uerr := out.UnmarshalMsg(prefix)
111 require.Error(t, uerr, "UnmarshalMsg should fail on prefix len %d", i)
112
113 var dec item
114 require.Error(t, dec.DecodeMsg(msgp.NewReader(bytes.NewReader(prefix))))
115 }
116}
117
118func Test_item_EncodeMsg_WriterErrors(t *testing.T) {
119 t.Parallel()

Callers

nothing calls this directly

Calls 5

UnmarshalMsgMethod · 0.95
DecodeMsgMethod · 0.95
populatedItemFunction · 0.85
ErrorMethod · 0.65
MarshalMsgMethod · 0.45

Tested by

no test coverage detected