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

Function TestMapCompareAndSwap

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

Source from the content-addressed store, hash-verified

107}
108
109func TestMapCompareAndSwap(t *testing.T) {
110 var m Map[int, string]
111 m.Store(1, "one")
112
113 ok := m.CompareAndSwap(1, "one", "uno")
114 if !ok {
115 t.Errorf("CompareAndSwap(1, 'one', 'uno') = false; want true")
116 }
117
118 v, _ := m.Load(1)
119 if v != "uno" {
120 t.Errorf("Load(1) after CompareAndSwap = %v; want 'uno'", v)
121 }
122}
123
124func TestMapCompareAndDelete(t *testing.T) {
125 var m Map[int, string]

Callers

nothing calls this directly

Calls 4

StoreMethod · 0.80
CompareAndSwapMethod · 0.80
ErrorfMethod · 0.80
LoadMethod · 0.80

Tested by

no test coverage detected