Fix: rand seeding error / Test: conf/version and util
This commit is contained in:
27
pkg/util/common_test.go
Normal file
27
pkg/util/common_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRandStringRunes(t *testing.T) {
|
||||
asserts := assert.New(t)
|
||||
|
||||
// 0 长度字符
|
||||
randStr := RandStringRunes(0)
|
||||
asserts.Len(randStr, 0)
|
||||
|
||||
// 16 长度字符
|
||||
randStr = RandStringRunes(16)
|
||||
asserts.Len(randStr, 16)
|
||||
|
||||
// 32 长度字符
|
||||
randStr = RandStringRunes(32)
|
||||
asserts.Len(randStr, 32)
|
||||
|
||||
//相同长度字符
|
||||
sameLenStr1 := RandStringRunes(32)
|
||||
sameLenStr2 := RandStringRunes(32)
|
||||
asserts.NotEqual(sameLenStr1, sameLenStr2)
|
||||
}
|
||||
Reference in New Issue
Block a user