MCPcopy
hub / github.com/openacid/slim / TestBase_Get

Function TestBase_Get

array/base_test.go:247–272  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

245}
246
247func TestBase_Get(t *testing.T) {
248
249 ta := require.New(t)
250
251 indexes := []int32{1, 3, 100}
252 elts := []uint16{1, 3, 100}
253
254 ab := &array.Base{}
255 ab.EltEncoder = encode.U16{}
256
257 // test empty array
258 ta.Panics(func() { ab.Get(1) })
259
260 err := ab.Init(indexes, elts)
261 ta.Nil(err)
262
263 for i, idx := range indexes {
264 v, found := ab.Get(idx)
265 ta.True(found)
266 ta.Equal(elts[i], v, "%d-th, %d expect %d found but: %v", i+1, idx, elts[i], v)
267
268 v, found = ab.Get(idx + 1)
269 ta.False(found)
270 ta.Nil(v)
271 }
272}
273
274var OutputBool bool
275

Callers

nothing calls this directly

Calls 2

GetMethod · 0.95
InitMethod · 0.95

Tested by

no test coverage detected