MCPcopy Index your code
hub / github.com/klauspost/compress / TestDecoderResetWithOptions

Function TestDecoderResetWithOptions

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

Source from the content-addressed store, hash-verified

2215}
2216
2217func TestDecoderResetWithOptions(t *testing.T) {
2218 dec, err := NewReader(nil, WithDecoderConcurrency(1), WithDecoderLowmem(true))
2219 if err != nil {
2220 t.Fatal(err)
2221 }
2222 defer dec.Close()
2223
2224 // Test changing safe options
2225 t.Run("change-maxmemory", func(t *testing.T) {
2226 err := dec.ResetWithOptions(nil, WithDecoderMaxMemory(1<<20))
2227 if err != nil {
2228 t.Errorf("ResetWithOptions should allow changing maxMemory: %v", err)
2229 }
2230 })
2231
2232 t.Run("change-maxwindow", func(t *testing.T) {
2233 err := dec.ResetWithOptions(nil, WithDecoderMaxWindow(1<<20))
2234 if err != nil {
2235 t.Errorf("ResetWithOptions should allow changing maxWindow: %v", err)
2236 }
2237 })
2238
2239 t.Run("change-ignorechecksum", func(t *testing.T) {
2240 err := dec.ResetWithOptions(nil, IgnoreChecksum(true))
2241 if err != nil {
2242 t.Errorf("ResetWithOptions should allow changing ignoreChecksum: %v", err)
2243 }
2244 })
2245
2246 // Test error when changing unsafe options
2247 t.Run("change-concurrency-error", func(t *testing.T) {
2248 err := dec.ResetWithOptions(nil, WithDecoderConcurrency(4))
2249 if err == nil {
2250 t.Error("ResetWithOptions should error when changing concurrency")
2251 }
2252 })
2253
2254 t.Run("change-lowmem-error", func(t *testing.T) {
2255 err := dec.ResetWithOptions(nil, WithDecoderLowmem(false))
2256 if err == nil {
2257 t.Error("ResetWithOptions should error when changing lowmem")
2258 }
2259 })
2260
2261 // Test same value is allowed
2262 t.Run("same-concurrency-ok", func(t *testing.T) {
2263 err := dec.ResetWithOptions(nil, WithDecoderConcurrency(1))
2264 if err != nil {
2265 t.Errorf("ResetWithOptions should allow same concurrency: %v", err)
2266 }
2267 })
2268}
2269
2270func TestDecoderDictDelete(t *testing.T) {
2271 dictContent := []byte("test dictionary content for decompression testing purposes")

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
WithDecoderConcurrencyFunction · 0.85
WithDecoderLowmemFunction · 0.85
WithDecoderMaxMemoryFunction · 0.85
WithDecoderMaxWindowFunction · 0.85
IgnoreChecksumFunction · 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…