(t *testing.T)
| 124 | } |
| 125 | |
| 126 | func TestConcurrentCountMap_ConcurrentIncrement(t *testing.T) { |
| 127 | const ( |
| 128 | key = 7 |
| 129 | concurrency = 8 |
| 130 | inc = 1000 |
| 131 | ) |
| 132 | |
| 133 | var m CountersMap[int] |
| 134 | |
| 135 | var wg sync.WaitGroup |
| 136 | |
| 137 | wg.Add(concurrency) |
| 138 | |
| 139 | for range concurrency { |
| 140 | go func() { |
| 141 | for range inc { |
| 142 | m.Increment(key) |
| 143 | } |
| 144 | |
| 145 | wg.Done() |
| 146 | }() |
| 147 | } |
| 148 | |
| 149 | wg.Wait() |
| 150 | |
| 151 | got, found := m.Get(key) |
| 152 | |
| 153 | require.True(t, found) |
| 154 | require.EqualValues(t, concurrency*inc, got) |
| 155 | } |