(t *testing.T)
| 115 | } |
| 116 | |
| 117 | func TestAtomicMap_MultipleThreads(t *testing.T) { |
| 118 | atomicMap := NewAtomicMap[string, int]() |
| 119 | |
| 120 | var wg sync.WaitGroup |
| 121 | |
| 122 | size := 1000 |
| 123 | wg.Add(size) |
| 124 | |
| 125 | for i := 0; i < size; i++ { |
| 126 | go func(idx int) { |
| 127 | key := fmt.Sprintf("key:%d", idx) |
| 128 | atomicMap.Set(key, 0) |
| 129 | atomicMap.RemoveKey(key) |
| 130 | atomicMap.Set(key, 0xbeef) |
| 131 | wg.Done() |
| 132 | }(i) |
| 133 | } |
| 134 | |
| 135 | wg.Wait() |
| 136 | |
| 137 | keys := atomicMap.Keys() |
| 138 | assert.Lenf(t, keys, size, "Map should have %d keys", size) |
| 139 | } |
nothing calls this directly
no test coverage detected