github.com/lingyao2333/mo-zero@v1.4.1/core/stringx/random_test.go (about) 1 package stringx 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestRand(t *testing.T) { 11 Seed(time.Now().UnixNano()) 12 assert.True(t, len(Rand()) > 0) 13 assert.True(t, len(RandId()) > 0) 14 15 const size = 10 16 assert.True(t, len(Randn(size)) == size) 17 } 18 19 func BenchmarkRandString(b *testing.B) { 20 for i := 0; i < b.N; i++ { 21 _ = Randn(10) 22 } 23 }