MCPcopy
hub / github.com/grafana/tempo / TestExtendReuseSlice

Function TestExtendReuseSlice

tempodb/encoding/vparquet3/schema_test.go:478–513  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

476}
477
478func TestExtendReuseSlice(t *testing.T) {
479 tcs := []struct {
480 sz int
481 in []int
482 expected []int
483 }{
484 {
485 sz: 0,
486 in: []int{1, 2, 3},
487 expected: []int{},
488 },
489 {
490 sz: 2,
491 in: []int{1, 2, 3},
492 expected: []int{1, 2},
493 },
494 {
495 sz: 5,
496 in: []int{1, 2, 3},
497 expected: []int{1, 2, 3, 0, 0},
498 },
499 {
500 // len < cap < sz: slice was shrunk then grown past cap
501 sz: 6,
502 in: append(make([]int, 0, 4), 1, 2),
503 expected: []int{1, 2, 0, 0, 0, 0},
504 },
505 }
506
507 for _, tc := range tcs {
508 t.Run(fmt.Sprintf("%v", tc.sz), func(t *testing.T) {
509 out := extendReuseSlice(tc.sz, tc.in)
510 assert.Equal(t, tc.expected, out)
511 })
512 }
513}
514
515func BenchmarkExtendReuseSlice(b *testing.B) {
516 in := []int{1, 2, 3}

Callers

nothing calls this directly

Calls 3

extendReuseSliceFunction · 0.70
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected