MCPcopy
hub / github.com/klauspost/compress / TestEncoder_SmallDict

Function TestEncoder_SmallDict

zstd/dict_test.go:148–286  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestEncoder_SmallDict(t *testing.T) {
149 // All files have CRC
150 zr := testCreateZipReader("testdata/dict-tests-small.zip", t)
151 var dicts [][]byte
152 var encs []*Encoder
153 var noDictEncs []*Encoder
154 var encNames []string
155
156 for _, tt := range zr.File {
157 if !strings.HasSuffix(tt.Name, ".dict") {
158 continue
159 }
160 func() {
161 r, err := tt.Open()
162 if err != nil {
163 t.Fatal(err)
164 }
165 defer r.Close()
166 in, err := io.ReadAll(r)
167 if err != nil {
168 t.Fatal(err)
169 }
170 dicts = append(dicts, in)
171 for level := SpeedFastest; level < speedLast; level++ {
172 if isRaceTest && level >= SpeedBestCompression {
173 break
174 }
175 enc, err := NewWriter(nil, WithEncoderConcurrency(1), WithEncoderDict(in), WithEncoderLevel(level), WithWindowSize(1<<17))
176 if err != nil {
177 t.Fatal(err)
178 }
179 encs = append(encs, enc)
180 encNames = append(encNames, fmt.Sprint("level-", level.String(), "-dict-", len(dicts)))
181
182 enc, err = NewWriter(nil, WithEncoderConcurrency(1), WithEncoderLevel(level), WithWindowSize(1<<17))
183 if err != nil {
184 t.Fatal(err)
185 }
186 noDictEncs = append(noDictEncs, enc)
187 }
188 }()
189 }
190 dec, err := NewReader(nil, WithDecoderConcurrency(1), WithDecoderDicts(dicts...))
191 if err != nil {
192 t.Fatal(err)
193 return
194 }
195 defer dec.Close()
196 for i, tt := range zr.File {
197 if testing.Short() && i > 100 {
198 break
199 }
200 if !strings.HasSuffix(tt.Name, ".zst") {
201 continue
202 }
203 r, err := tt.Open()
204 if err != nil {
205 t.Fatal(err)

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
WriteMethod · 0.95
CloseMethod · 0.95
testCreateZipReaderFunction · 0.85
WithEncoderConcurrencyFunction · 0.85
WithEncoderDictFunction · 0.85
WithEncoderLevelFunction · 0.85
WithWindowSizeFunction · 0.85
WithDecoderConcurrencyFunction · 0.85
WithDecoderDictsFunction · 0.85
FatalMethod · 0.80
DecodeAllMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…