mirror of
https://github.com/golang/go
synced 2024-11-21 22:34:48 -07:00
strings: adjust and add tests for strings.Index and strings.LastIndex
A strings.Index test is implemented in ExampleLastIndex, so moved to ExampleIndex. strings.Index and strings.LastIndex do not have empty substr test, so added them. Change-Id: I9ba6099467addf35b7b6df6840c3278cccca4892
This commit is contained in:
parent
6ae3b70ef2
commit
0d7c239f59
@ -107,9 +107,13 @@ func ExampleHasSuffix() {
|
||||
}
|
||||
|
||||
func ExampleIndex() {
|
||||
fmt.Println(strings.Index("go gopher", "go"))
|
||||
fmt.Println(strings.Index("go gopher", ""))
|
||||
fmt.Println(strings.Index("chicken", "ken"))
|
||||
fmt.Println(strings.Index("chicken", "dmr"))
|
||||
// Output:
|
||||
// 0
|
||||
// 0
|
||||
// 4
|
||||
// -1
|
||||
}
|
||||
@ -151,12 +155,12 @@ func ExampleIndexRune() {
|
||||
}
|
||||
|
||||
func ExampleLastIndex() {
|
||||
fmt.Println(strings.Index("go gopher", "go"))
|
||||
fmt.Println(strings.LastIndex("go gopher", "go"))
|
||||
fmt.Println(strings.LastIndex("go gopher", ""))
|
||||
fmt.Println(strings.LastIndex("go gopher", "rodent"))
|
||||
// Output:
|
||||
// 0
|
||||
// 3
|
||||
// 9
|
||||
// -1
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user