Test_item_Decode_FieldLimits covers the per-field ErrLimitExceeded branches of the item byte fields.
(t *testing.T)
| 249 | // Test_item_Decode_FieldLimits covers the per-field ErrLimitExceeded branches |
| 250 | // of the item byte fields. |
| 251 | func Test_item_Decode_FieldLimits(t *testing.T) { |
| 252 | t.Parallel() |
| 253 | |
| 254 | cases := []struct { |
| 255 | field string |
| 256 | size int |
| 257 | }{ |
| 258 | {"ctype", 257}, |
| 259 | {"cencoding", 129}, |
| 260 | {"cacheControl", 2049}, |
| 261 | {"expires", 129}, |
| 262 | {"etag", 257}, |
| 263 | } |
| 264 | for _, tc := range cases { |
| 265 | var raw []byte |
| 266 | raw = msgp.AppendMapHeader(raw, 1) |
| 267 | raw = msgp.AppendString(raw, tc.field) |
| 268 | raw = msgp.AppendBytes(raw, make([]byte, tc.size)) |
| 269 | |
| 270 | var out item |
| 271 | _, err := out.UnmarshalMsg(raw) |
| 272 | require.ErrorIs(t, err, msgp.ErrLimitExceeded, "field %s", tc.field) |
| 273 | |
| 274 | var dec item |
| 275 | require.ErrorIs(t, dec.DecodeMsg(msgp.NewReader(bytes.NewReader(raw))), msgp.ErrLimitExceeded, "field %s", tc.field) |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | func Test_indexedHeap_PushAndOps(t *testing.T) { |
| 280 | t.Parallel() |
nothing calls this directly
no test coverage detected