mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-17 11:12:28 +08:00
fix: fix test case TestConcurrentMap_GetAndDelete
This commit is contained in:
@@ -100,12 +100,18 @@ func TestConcurrentMap_GetAndDelete(t *testing.T) {
|
|||||||
|
|
||||||
cm := NewConcurrentMap[string, int](100)
|
cm := NewConcurrentMap[string, int](100)
|
||||||
|
|
||||||
|
var wg1 sync.WaitGroup
|
||||||
|
wg1.Add(10)
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
go func(n int) {
|
go func(n int) {
|
||||||
cm.Set(fmt.Sprintf("%d", n), n)
|
cm.Set(fmt.Sprintf("%d", n), n)
|
||||||
|
wg1.Done()
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
|
wg1.Wait()
|
||||||
|
|
||||||
|
var wg2 sync.WaitGroup
|
||||||
|
wg2.Add(10)
|
||||||
for j := 0; j < 10; j++ {
|
for j := 0; j < 10; j++ {
|
||||||
go func(n int) {
|
go func(n int) {
|
||||||
val, ok := cm.GetAndDelete(fmt.Sprintf("%d", n))
|
val, ok := cm.GetAndDelete(fmt.Sprintf("%d", n))
|
||||||
@@ -114,8 +120,11 @@ func TestConcurrentMap_GetAndDelete(t *testing.T) {
|
|||||||
|
|
||||||
_, ok = cm.Get(fmt.Sprintf("%d", n))
|
_, ok = cm.Get(fmt.Sprintf("%d", n))
|
||||||
assert.Equal(false, ok)
|
assert.Equal(false, ok)
|
||||||
|
wg2.Done()
|
||||||
}(j)
|
}(j)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg2.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConcurrentMap_Has(t *testing.T) {
|
func TestConcurrentMap_Has(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user