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

Function TestMap_LoadOrStore

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

Source from the content-addressed store, hash-verified

118}
119
120func TestMap_LoadOrStore(t *testing.T) {
121 t.Parallel()
122 m := NewMap[string, int]()
123
124 val, loaded := m.LoadOrStore("a", 1)
125 assert.False(t, loaded)
126 assert.Equal(t, 1, val)
127
128 val, loaded = m.LoadOrStore("a", 2)
129 assert.True(t, loaded)
130 assert.Equal(t, 1, val)
131
132 // The original value is preserved even after a same-key LoadOrStore.
133 val, ok := m.Load("a")
134 assert.True(t, ok)
135 assert.Equal(t, 1, val)
136}
137
138func TestMap_LoadOrStoreZeroValue(t *testing.T) {
139 t.Parallel()

Callers

nothing calls this directly

Calls 3

NewMapFunction · 0.85
LoadOrStoreMethod · 0.80
LoadMethod · 0.80

Tested by

no test coverage detected