github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/sync/map_test.go (about)

     1  package sync_test
     2  
     3  import (
     4  	"sync"
     5  	"testing"
     6  )
     7  
     8  func 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  }