Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
test: add unit test case for func TransRate
Browse files Browse the repository at this point in the history
Signed-off-by: Guangwen Feng <[email protected]>
  • Loading branch information
Guangwen Feng committed Dec 30, 2019
1 parent df32ce2 commit d1d7b0a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/ratelimiter/ratelimiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,20 @@ func (suite *RateLimiterSuite) TestRateLimiter_AcquireNonBlocking(c *check.C) {
rl.blocking(1000)
c.Assert(rl.AcquireNonBlocking(1000), check.Equals, int64(1000))
}

func (suite *RateLimiterSuite) TestTransRate(c *check.C) {
var cases = []struct {
r int64
e int64
}{
{666, 1000},
{2048, 3000},
{123456, 124000},
{0, 10486000},
{-233, 10486000},
}
for _, cc := range cases {
v := TransRate(cc.r)
c.Assert(v, check.Equals, cc.e)
}
}

0 comments on commit d1d7b0a

Please sign in to comment.