You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
367 B
Go
24 lines
367 B
Go
4 years ago
|
package stringx
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestRand(t *testing.T) {
|
||
|
Seed(time.Now().UnixNano())
|
||
|
assert.True(t, len(Rand()) > 0)
|
||
|
assert.True(t, len(RandId()) > 0)
|
||
|
|
||
|
const size = 10
|
||
|
assert.True(t, len(Randn(size)) == size)
|
||
|
}
|
||
|
|
||
|
func BenchmarkRandString(b *testing.B) {
|
||
|
for i := 0; i < b.N; i++ {
|
||
|
_ = Randn(10)
|
||
|
}
|
||
|
}
|