support importing transaction data from alipay export file
This commit is contained in:
@@ -76,6 +76,21 @@ func GetFirstLowerCharString(s string) string {
|
||||
return string(chars)
|
||||
}
|
||||
|
||||
// ContainsOnlyOneRune returns the source string only contains one character
|
||||
func ContainsOnlyOneRune(s string, r rune) bool {
|
||||
if len(s) < 1 {
|
||||
return false
|
||||
}
|
||||
|
||||
for i := 0; i < len(s); i++ {
|
||||
if rune(s[i]) != r {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// GetRandomString returns a random string of which length is n
|
||||
func GetRandomString(n int) (string, error) {
|
||||
var result = make([]byte, n)
|
||||
|
||||
@@ -82,6 +82,14 @@ func TestGetFirstLowerCharString(t *testing.T) {
|
||||
assert.Equal(t, expectedValue, actualValue)
|
||||
}
|
||||
|
||||
func TestContainsOnlyOneRune(t *testing.T) {
|
||||
actualValue := ContainsOnlyOneRune("-------", '-')
|
||||
assert.Equal(t, true, actualValue)
|
||||
|
||||
actualValue = ContainsOnlyOneRune(" -------", '-')
|
||||
assert.Equal(t, false, actualValue)
|
||||
}
|
||||
|
||||
func TestGetRandomString(t *testing.T) {
|
||||
actualValue, err := GetRandomString(10)
|
||||
assert.Equal(t, nil, err)
|
||||
|
||||
Reference in New Issue
Block a user