support importing transaction data from alipay export file

This commit is contained in:
MaysWind
2024-09-22 19:27:20 +08:00
parent 732fa3b9de
commit 52b37c2a13
19 changed files with 826 additions and 79 deletions
+15
View File
@@ -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)
+8
View File
@@ -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)