mirror of
https://github.com/ManyakRus/starter.git
synced 2025-02-19 19:59:50 +02:00
сделал FindLastPos()
This commit is contained in:
parent
b244937e95
commit
3dfaad5139
@ -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
|
||||
}
|
||||
|
@ -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 !")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user