MCPcopy
hub / github.com/dgraph-io/dgraph / TestDecoder

Function TestDecoder

codec/codec_test.go:190–217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

188}
189
190func TestDecoder(t *testing.T) {
191 N := 10001
192 var expected []uint64
193 enc := Encoder{BlockSize: 10}
194 for i := 3; i < N; i += 3 {
195 enc.Add(uint64(i))
196 expected = append(expected, uint64(i))
197 }
198 pack := enc.Done()
199 defer FreePack(pack)
200
201 dec := Decoder{Pack: pack}
202 for i := 3; i < N; i += 3 {
203 uids := dec.Seek(uint64(i), SeekStart)
204 require.Equal(t, uint64(i), uids[0])
205
206 uids = dec.Seek(uint64(i-1), SeekStart)
207 require.Equal(t, uint64(i), uids[0])
208
209 uids = dec.Seek(uint64(i-2), SeekStart)
210 require.Equal(t, uint64(i), uids[0])
211
212 start := i/3 - 1
213 actual := Decode(pack, uint64(i))
214 require.Equal(t, expected[start:], actual)
215
216 }
217}
218
219func BenchmarkGzip(b *testing.B) {
220 uids := getUids(1e6)

Callers

nothing calls this directly

Calls 5

AddMethod · 0.95
DoneMethod · 0.95
SeekMethod · 0.95
FreePackFunction · 0.85
DecodeFunction · 0.85

Tested by

no test coverage detected