mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
sync: implement map.LoadAndDelete
This commit is contained in:
@@ -0,0 +1,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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user