mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-14 01:32:27 +08:00
fix: fix TestConcurrentMap_Delete test failed
This commit is contained in:
@@ -42,13 +42,18 @@ func TestConcurrentMap_GetOrSet(t *testing.T) {
|
|||||||
|
|
||||||
cm := NewConcurrentMap[string, int](100)
|
cm := NewConcurrentMap[string, int](100)
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
wg.Add(5)
|
||||||
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
go func(n int) {
|
go func(n int) {
|
||||||
val, ok := cm.GetOrSet(fmt.Sprintf("%d", n), n)
|
val, ok := cm.GetOrSet(fmt.Sprintf("%d", n), n)
|
||||||
assert.Equal(n, val)
|
assert.Equal(n, val)
|
||||||
assert.Equal(false, ok)
|
assert.Equal(false, ok)
|
||||||
|
wg.Done()
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
for j := 0; j < 5; j++ {
|
for j := 0; j < 5; j++ {
|
||||||
go func(n int) {
|
go func(n int) {
|
||||||
|
|||||||
Reference in New Issue
Block a user