(t *testing.T)
| 2215 | } |
| 2216 | |
| 2217 | func 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 | |
| 2270 | func TestDecoderDictDelete(t *testing.T) { |
| 2271 | dictContent := []byte("test dictionary content for decompression testing purposes") |
nothing calls this directly
no test coverage detected
searching dependent graphs…