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

Function TestEncoding

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

Source from the content-addressed store, hash-verified

304}
305
306func TestEncoding(t *testing.T) {
307 bigInts := make([]uint64, 5)
308 bigInts[0] = 0xf000000000000000
309 bigInts[1] = 0xf00f000000000000
310 bigInts[2] = 0x00f00f0000000000
311 bigInts[3] = 0x000f0f0000000000
312 bigInts[4] = 0x0f0f0f0f00000000
313
314 var lengths = []int{0, 1, 2, 3, 5, 13, 18, 100, 99, 98}
315
316 for tc := range lengths {
317 ints := make([]uint64, lengths[tc])
318
319 for i := 0; i < 50 && i < lengths[tc]; i++ {
320 ints[i] = uint64(rand.Uint32())
321 }
322
323 for i := 50; i < lengths[tc]; i++ {
324 ints[i] = uint64(rand.Uint32()) + bigInts[rand.Intn(5)]
325 }
326
327 sort.Slice(ints, func(i, j int) bool { return ints[i] < ints[j] })
328
329 encodedInts := Encode(ints, 256)
330 decodedInts := Decode(encodedInts, 0)
331
332 require.Equal(t, ints, decodedInts)
333 }
334}
335
336func newUidPack(data []uint64) *pb.UidPack {
337 encoder := Encoder{BlockSize: 10}

Callers

nothing calls this directly

Calls 3

EncodeFunction · 0.85
DecodeFunction · 0.85
SliceMethod · 0.80

Tested by

no test coverage detected