MCPcopy Create free account
hub / github.com/klauspost/compress / TestDecoderDictDelete

Function TestDecoderDictDelete

zstd/decoder_test.go:2270–2312  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2268}
2269
2270func TestDecoderDictDelete(t *testing.T) {
2271 dictContent := []byte("test dictionary content for decompression testing purposes")
2272
2273 dec, err := NewReader(nil, WithDecoderDictRaw(100, dictContent), WithDecoderDictRaw(200, dictContent))
2274 if err != nil {
2275 t.Fatal(err)
2276 }
2277 defer dec.Close()
2278
2279 if len(dec.o.dicts) != 2 {
2280 t.Fatalf("expected 2 dicts, got %d", len(dec.o.dicts))
2281 }
2282
2283 // Delete specific dict
2284 err = dec.ResetWithOptions(nil, WithDecoderDictDelete(100))
2285 if err != nil {
2286 t.Fatal(err)
2287 }
2288 if len(dec.o.dicts) != 1 {
2289 t.Errorf("expected 1 dict after delete, got %d", len(dec.o.dicts))
2290 }
2291 if _, ok := dec.o.dicts[200]; !ok {
2292 t.Error("dict 200 should still exist")
2293 }
2294
2295 // Add another dict
2296 err = dec.ResetWithOptions(nil, WithDecoderDictRaw(300, dictContent))
2297 if err != nil {
2298 t.Fatal(err)
2299 }
2300 if len(dec.o.dicts) != 2 {
2301 t.Errorf("expected 2 dicts after add, got %d", len(dec.o.dicts))
2302 }
2303
2304 // Delete all dicts with no arguments
2305 err = dec.ResetWithOptions(nil, WithDecoderDictDelete())
2306 if err != nil {
2307 t.Fatal(err)
2308 }
2309 if len(dec.o.dicts) != 0 {
2310 t.Errorf("expected 0 dicts after delete all, got %d", len(dec.o.dicts))
2311 }
2312}
2313
2314func TestDecoderDictDeleteMultiple(t *testing.T) {
2315 dictContent := []byte("test dictionary content")

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
WithDecoderDictRawFunction · 0.85
WithDecoderDictDeleteFunction · 0.85
FatalMethod · 0.80
NewReaderFunction · 0.70
ResetWithOptionsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…