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

Function TestMap_RangeCallbackCanMutate

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

Source from the content-addressed store, hash-verified

90}
91
92func 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
108func TestMap_ZeroValueStore(t *testing.T) {
109 t.Parallel()

Callers

nothing calls this directly

Calls 4

NewMapFunction · 0.85
StoreMethod · 0.45
RangeMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected