123456789101112131415161718192021222324252627282930313233343536 |
- package util
- import (
- "testing"
- "github.com/nsqio/nsq/internal/test"
- )
- func BenchmarkUniqRands5of5(b *testing.B) {
- for i := 0; i < b.N; i++ {
- UniqRands(5, 5)
- }
- }
- func BenchmarkUniqRands20of20(b *testing.B) {
- for i := 0; i < b.N; i++ {
- UniqRands(20, 20)
- }
- }
- func BenchmarkUniqRands20of50(b *testing.B) {
- for i := 0; i < b.N; i++ {
- UniqRands(20, 50)
- }
- }
- func TestUniqRands(t *testing.T) {
- var x []int
- x = UniqRands(3, 10)
- test.Equal(t, 3, len(x))
- x = UniqRands(10, 5)
- test.Equal(t, 5, len(x))
- x = UniqRands(10, 20)
- test.Equal(t, 10, len(x))
- }
|