support the latest format of alipay statement file
This commit is contained in:
@@ -60,6 +60,17 @@ func SubString(str string, start int, length int) string {
|
||||
return string(chars[start:end])
|
||||
}
|
||||
|
||||
// ContainsAnyString returns whether the specified string contains any string of sub string slice
|
||||
func ContainsAnyString(s string, substrs []string) bool {
|
||||
for i := 0; i < len(substrs); i++ {
|
||||
if strings.Index(s, substrs[i]) >= 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// GetFirstLowerCharString returns the source string parameter, but makes the first character lower case
|
||||
func GetFirstLowerCharString(s string) string {
|
||||
if s == "" {
|
||||
|
||||
@@ -72,6 +72,20 @@ func TestSubString_OverBoundary(t *testing.T) {
|
||||
assert.Equal(t, expectedValue, actualValue)
|
||||
}
|
||||
|
||||
func TestContainsAnyString(t *testing.T) {
|
||||
actualValue := ContainsAnyString("test", []string{"test"})
|
||||
assert.Equal(t, true, actualValue)
|
||||
|
||||
actualValue = ContainsAnyString("test", []string{"st"})
|
||||
assert.Equal(t, true, actualValue)
|
||||
|
||||
actualValue = ContainsAnyString("test", []string{"tt", "tet", "tst", "est"})
|
||||
assert.Equal(t, true, actualValue)
|
||||
|
||||
actualValue = ContainsAnyString("test", []string{"tt", "tet", "tst"})
|
||||
assert.Equal(t, false, actualValue)
|
||||
}
|
||||
|
||||
func TestGetFirstLowerCharString(t *testing.T) {
|
||||
expectedValue := "fooBar"
|
||||
actualValue := GetFirstLowerCharString("fooBar")
|
||||
|
||||
Reference in New Issue
Block a user