MCPcopy
hub / github.com/nats-io/nats.go / TestMapSwap

Function TestMapSwap

internal/syncx/map_test.go:139–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestMapSwap(t *testing.T) {
140 var m Map[int, string]
141 m.Store(1, "one")
142
143 v, loaded := m.Swap(1, "uno")
144 if !loaded || v != "one" {
145 t.Errorf("Swap(1, 'uno') = %v, %v; want 'one', true", v, loaded)
146 }
147
148 v, _ = m.Load(1)
149 if v != "uno" {
150 t.Errorf("Load(1) after Swap = %v; want 'uno'", v)
151 }
152}

Callers

nothing calls this directly

Calls 4

StoreMethod · 0.80
SwapMethod · 0.80
ErrorfMethod · 0.80
LoadMethod · 0.80

Tested by

no test coverage detected