1
0
mirror of https://github.com/ManyakRus/starter.git synced 2025-02-19 19:59:50 +02:00

сделал FindLastPos()

This commit is contained in:
Nikitin Aleksandr 2024-02-12 13:29:20 +03:00
parent b244937e95
commit 3dfaad5139
2 changed files with 14 additions and 0 deletions

View File

@ -802,3 +802,9 @@ func Int64FromString(s string) (int64, error) {
return Otvet, err
}
// FindLastPos - возвращает позицию последнего вхождения
func FindLastPos(s, TextFind string) int {
Otvet := strings.LastIndex(s, TextFind)
return Otvet
}

View File

@ -546,3 +546,11 @@ func TestInt64FromString(t *testing.T) {
t.Errorf("Expected %d, but got: %d", expected3, result3)
}
}
func TestFindLastPos(t *testing.T) {
s := "Hello, World!"
pos1 := FindLastPos(s, " ")
if pos1 < 0 {
t.Error("microfunctions_test.TestFindLastPos() FindLastPos()=nil !")
}
}