(t *testing.T)
| 90 | } |
| 91 | |
| 92 | func TestMap_RangeCallbackCanMutate(t *testing.T) { |
| 93 | t.Parallel() |
| 94 | // Range iterates over a snapshot, so callbacks may safely mutate the map |
| 95 | // without deadlocking. |
| 96 | m := NewMap[string, int]() |
| 97 | m.Store("a", 1) |
| 98 | m.Store("b", 2) |
| 99 | |
| 100 | m.Range(func(k string, _ int) bool { |
| 101 | m.Store(k+"!", 0) |
| 102 | return true |
| 103 | }) |
| 104 | |
| 105 | assert.Equal(t, 4, m.Length()) |
| 106 | } |
| 107 | |
| 108 | func TestMap_ZeroValueStore(t *testing.T) { |
| 109 | t.Parallel() |