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

Function TestExtendReuseSlice

tempodb/encoding/vparquet4/schema_test.go:888–923  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

886}
887
888func TestExtendReuseSlice(t *testing.T) {
889 tcs := []struct {
890 sz int
891 in []int
892 expected []int
893 }{
894 {
895 sz: 0,
896 in: []int{1, 2, 3},
897 expected: []int{},
898 },
899 {
900 sz: 2,
901 in: []int{1, 2, 3},
902 expected: []int{1, 2},
903 },
904 {
905 sz: 5,
906 in: []int{1, 2, 3},
907 expected: []int{1, 2, 3, 0, 0},
908 },
909 {
910 // len < cap < sz: slice was shrunk then grown past cap
911 sz: 6,
912 in: append(make([]int, 0, 4), 1, 2),
913 expected: []int{1, 2, 0, 0, 0, 0},
914 },
915 }
916
917 for _, tc := range tcs {
918 t.Run(fmt.Sprintf("%v", tc.sz), func(t *testing.T) {
919 out := extendReuseSlice(tc.sz, tc.in)
920 assert.Equal(t, tc.expected, out)
921 })
922 }
923}
924
925func BenchmarkExtendReuseSlice(b *testing.B) {
926 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