Skip to content

Commit 6ae72d6

Browse files
committed
完善单元测试
1 parent 6ad4dbc commit 6ae72d6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

limiter_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ func TestLimiter(t *testing.T) {
1818
var countMap = make(map[int64]int, 16)
1919
var lock sync.Mutex
2020

21-
totalCount := 100
21+
totalCount := 10 * limit
2222
for i := 0; i < totalCount; i++ {
2323
limiter.Go(func() {
24-
now := time.Now().UnixMilli()
24+
now := time.Now().UnixMilli() / 10
2525

2626
lock.Lock()
2727
countMap[now] = countMap[now] + 1
2828
lock.Unlock()
2929

30-
time.Sleep(100 * time.Millisecond)
30+
time.Sleep(10 * time.Millisecond)
3131
})
3232
}
3333

@@ -38,7 +38,7 @@ func TestLimiter(t *testing.T) {
3838
gotTotalCount = gotTotalCount + count
3939

4040
if count != limit {
41-
t.Logf("now %d: count %d != limit %d", now, count, limit)
41+
t.Fatalf("now %d: count %d != limit %d", now, count, limit)
4242
}
4343
}
4444

0 commit comments

Comments
 (0)