MCPcopy Create free account
hub / github.com/google/gapid / TestInsertBefore

Function TestInsertBefore

core/data/slice/slice_test.go:122–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

120}
121
122func TestInsertBefore(t *testing.T) {
123 ctx := log.Testing(t)
124
125 for _, test := range []struct {
126 data []int
127 at int
128 val interface{}
129 expected []int
130 }{
131 // Insertion (with: slice).
132 {[]int{1, 2, 3}, 0, []int{9}, []int{9, 1, 2, 3}},
133 {[]int{1, 2, 3}, 1, []int{9}, []int{1, 9, 2, 3}},
134 {[]int{1, 2, 3}, 2, []int{9}, []int{1, 2, 9, 3}},
135
136 // Insertion (with: element).
137 {[]int{1, 2, 3}, 0, 9, []int{9, 1, 2, 3}},
138 {[]int{1, 2, 3}, 1, 9, []int{1, 9, 2, 3}},
139 {[]int{1, 2, 3}, 2, 9, []int{1, 2, 9, 3}},
140 } {
141 got := make([]int, len(test.data))
142 copy(got, test.data)
143 slice.InsertBefore(&got, test.at, test.val)
144 assert.For(ctx, "InsertBefore(%v, %v, %v)", test.data, test.at, test.val).
145 That(got).DeepEquals(test.expected)
146 }
147}
148
149func TestAppend(t *testing.T) {
150 ctx := log.Testing(t)

Callers

nothing calls this directly

Calls 4

InsertBeforeMethod · 0.80
ThatMethod · 0.80
ForMethod · 0.80
DeepEqualsMethod · 0.45

Tested by

no test coverage detected