Improve gflock unit testing.

This commit is contained in:
hailaz 2019-06-24 17:33:56 +08:00
parent 0f14002b05
commit 3806f9db07

View File

@ -79,20 +79,20 @@ func Test_GFlock_RLock(t *testing.T) {
go func() {
lock.RLock()
array.Append(1)
time.Sleep(200 * time.Millisecond)
time.Sleep(400 * time.Millisecond)
lock.RUnlock()
}()
go func() {
time.Sleep(50 * time.Millisecond)
time.Sleep(200 * time.Millisecond)
lock2.RLock()
array.Append(1)
lock2.RUnlock()
}()
time.Sleep(50 * time.Millisecond)
gtest.Assert(array.Len(), 1)
time.Sleep(100 * time.Millisecond)
gtest.Assert(array.Len(), 1)
time.Sleep(200 * time.Millisecond)
gtest.Assert(array.Len(), 2)
})
}