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

Function TestExtendReuseSlice

tempodb/encoding/vparquet5/schema_test.go:909–944  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

907}
908
909func TestExtendReuseSlice(t *testing.T) {
910 tcs := []struct {
911 sz int
912 in []int
913 expected []int
914 }{
915 {
916 sz: 0,
917 in: []int{1, 2, 3},
918 expected: []int{},
919 },
920 {
921 sz: 2,
922 in: []int{1, 2, 3},
923 expected: []int{1, 2},
924 },
925 {
926 sz: 5,
927 in: []int{1, 2, 3},
928 expected: []int{1, 2, 3, 0, 0},
929 },
930 {
931 // len < cap < sz: slice was shrunk then grown past cap
932 sz: 6,
933 in: append(make([]int, 0, 4), 1, 2),
934 expected: []int{1, 2, 0, 0, 0, 0},
935 },
936 }
937
938 for _, tc := range tcs {
939 t.Run(fmt.Sprintf("%v", tc.sz), func(t *testing.T) {
940 out := extendReuseSlice(tc.sz, tc.in)
941 assert.Equal(t, tc.expected, out)
942 })
943 }
944}
945
946func BenchmarkExtendReuseSlice(b *testing.B) {
947 sizes := []int{5, 20, 8, 50, 12, 100, 30, 200, 15, 80, 3, 150, 10, 40, 7, 300, 25, 60, 90, 10}

Callers

nothing calls this directly

Calls 3

extendReuseSliceFunction · 0.70
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected