MCPcopy
hub / github.com/tinygo-org/tinygo / TestMapLoadAndDelete

Function TestMapLoadAndDelete

src/sync/map_test.go:8–19  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestMapLoadAndDelete(t *testing.T) {
9 var sm sync.Map
10 sm.Store("present", "value")
11
12 if v, ok := sm.LoadAndDelete("present"); !ok || v != "value" {
13 t.Errorf("LoadAndDelete returned %v, %v, want value, true", v, ok)
14 }
15
16 if v, ok := sm.LoadAndDelete("absent"); ok || v != nil {
17 t.Errorf("LoadAndDelete returned %v, %v, want nil, false", v, ok)
18 }
19}
20
21func TestMapSwap(t *testing.T) {
22 var sm sync.Map

Callers

nothing calls this directly

Calls 3

StoreMethod · 0.95
LoadAndDeleteMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected