mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
improve unit testing case for package gtimer
This commit is contained in:
@ -102,7 +102,7 @@ func TestDelayAddEntry(t *testing.T) {
|
||||
func TestDelayAddSingleton(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
array := garray.New(true)
|
||||
gtimer.DelayAddSingleton(200*time.Millisecond, 200*time.Millisecond, func() {
|
||||
gtimer.DelayAddSingleton(500*time.Millisecond, 500*time.Millisecond, func() {
|
||||
array.Append(1)
|
||||
time.Sleep(10000 * time.Millisecond)
|
||||
})
|
||||
@ -129,12 +129,12 @@ func TestDelayAddOnce(t *testing.T) {
|
||||
func TestDelayAddTimes(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
array := garray.New(true)
|
||||
gtimer.DelayAddTimes(200*time.Millisecond, 200*time.Millisecond, 2, func() {
|
||||
gtimer.DelayAddTimes(500*time.Millisecond, 500*time.Millisecond, 2, func() {
|
||||
array.Append(1)
|
||||
})
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
t.Assert(array.Len(), 0)
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
time.Sleep(1500 * time.Millisecond)
|
||||
t.Assert(array.Len(), 2)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user