MCPcopy
hub / github.com/cornelk/hashmap / TestResize

Function TestResize

hashmap_test.go:181–207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

179}
180
181func TestResize(t *testing.T) {
182 t.Parallel()
183 m := NewSized[uintptr, string](2)
184 itemCount := uintptr(50)
185
186 for i := uintptr(0); i < itemCount; i++ {
187 m.Set(i, strconv.Itoa(int(i)))
188 }
189
190 assert.Equal(t, itemCount, m.Len())
191
192 for { // make sure to wait for resize operation to finish
193 if m.resizing.Load() == 0 {
194 break
195 }
196 time.Sleep(time.Microsecond * 50)
197 }
198
199 assert.True(t, m.FillRate() > 30)
200
201 for i := uintptr(0); i < itemCount; i++ {
202 value, ok := m.Get(i)
203 assert.True(t, ok)
204 expected := strconv.Itoa(int(i))
205 assert.Equal(t, expected, value)
206 }
207}
208
209func TestStringer(t *testing.T) {
210 t.Parallel()

Callers

nothing calls this directly

Calls 6

EqualFunction · 0.92
TrueFunction · 0.92
SetMethod · 0.80
FillRateMethod · 0.80
GetMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…