1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 16:22:26 +08:00

fix: The LastIndexOf method can never return the index of the first element (#83)

Co-authored-by: JiangCheng <jiangcheng@kezaihui.com>
This commit is contained in:
Mickls
2023-03-28 20:02:57 +08:00
committed by GitHub
parent f09e521783
commit 3b497532f3
2 changed files with 6 additions and 5 deletions

View File

@@ -665,8 +665,8 @@ func TestDifferenceWith(t *testing.T) {
func TestDifferenceBy(t *testing.T) {
assert := internal.NewAssert(t, "TestDifferenceBy")
s1 := []int{1, 2, 3, 4, 5} //after add one: 2 3 4 5 6
s2 := []int{3, 4, 5} //after add one: 4 5 6
s1 := []int{1, 2, 3, 4, 5} // after add one: 2 3 4 5 6
s2 := []int{3, 4, 5} // after add one: 4 5 6
addOne := func(i int, v int) int {
return v + 1
}
@@ -873,8 +873,9 @@ func TestIndexOf(t *testing.T) {
func TestLastIndexOf(t *testing.T) {
assert := internal.NewAssert(t, "TestLastIndexOf")
arr := []string{"a", "a", "b", "c"}
assert.Equal(1, LastIndexOf(arr, "a"))
arr := []string{"a", "b", "b", "c"}
assert.Equal(0, LastIndexOf(arr, "a"))
assert.Equal(2, LastIndexOf(arr, "b"))
assert.Equal(-1, LastIndexOf(arr, "d"))
}