aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sync/map_test.go
blob: f493bdfb51aa0c89b953e3c554dc5202028f071e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package sync_test

import (
	"sync"
	"testing"
)

func TestMapLoadAndDelete(t *testing.T) {
	var sm sync.Map
	sm.Store("present", "value")

	if v, ok := sm.LoadAndDelete("present"); !ok || v != "value" {
		t.Errorf("LoadAndDelete returned %v, %v, want value, true", v, ok)
	}

	if v, ok := sm.LoadAndDelete("absent"); ok || v != nil {
		t.Errorf("LoadAndDelete returned %v, %v, want nil, false", v, ok)
	}
}