| 179 | } |
| 180 | |
| 181 | func 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 | |
| 209 | func TestStringer(t *testing.T) { |
| 210 | t.Parallel() |