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

Function TestMap_Range

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

Source from the content-addressed store, hash-verified

67}
68
69func TestMap_Range(t *testing.T) {
70 t.Parallel()
71 m := NewMap[string, int]()
72 m.Store("a", 1)
73 m.Store("b", 2)
74 m.Store("c", 3)
75
76 collected := map[string]int{}
77 m.Range(func(k string, v int) bool {
78 collected[k] = v
79 return true
80 })
81 assert.Equal(t, map[string]int{"a": 1, "b": 2, "c": 3}, collected)
82
83 // Early termination: stop after the first element.
84 count := 0
85 m.Range(func(_ string, _ int) bool {
86 count++
87 return false
88 })
89 assert.Equal(t, 1, count)
90}
91
92func TestMap_RangeCallbackCanMutate(t *testing.T) {
93 t.Parallel()

Callers

nothing calls this directly

Calls 3

NewMapFunction · 0.85
StoreMethod · 0.45
RangeMethod · 0.45

Tested by

no test coverage detected