MCPcopy Index your code
hub / github.com/docker/docker-agent / TestMap_Concurrent

Function TestMap_Concurrent

pkg/concurrent/map_test.go:177–198  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

175}
176
177func TestMap_Concurrent(t *testing.T) {
178 t.Parallel()
179 m := NewMap[int, int]()
180 var wg sync.WaitGroup
181
182 for i := range 100 {
183 wg.Add(1)
184 go func(n int) {
185 defer wg.Done()
186 m.Store(n, n*2)
187 }(i)
188 }
189
190 wg.Wait()
191 require.Equal(t, 100, m.Length())
192
193 for i := range 100 {
194 val, ok := m.Load(i)
195 require.True(t, ok)
196 require.Equal(t, i*2, val)
197 }
198}
199
200func TestMap_Clear(t *testing.T) {
201 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewMapFunction · 0.85
LoadMethod · 0.80
AddMethod · 0.65
WaitMethod · 0.65
StoreMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected