test(listx): add listx remove
This commit is contained in:
parent
4f6fb64ecc
commit
7ce1a55d0e
|
@ -204,3 +204,25 @@ func TestListx_Range(t *testing.T) {
|
|||
_, err = list.Range(6, -1)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestListx_Remove(t *testing.T) {
|
||||
list := NewListXSingle()
|
||||
list.RPush("a", "b", "c", "c", "e")
|
||||
|
||||
count, up := list.Remove("c", -2)
|
||||
require.Equal(t, count, 2)
|
||||
require.Equal(t, int(up), 34)
|
||||
|
||||
res, _ := list.LPop(list.Length())
|
||||
require.Equal(t, res, []string{"a", "b", "e"})
|
||||
|
||||
list = NewListXSingle()
|
||||
list.RPush("a", "b", "c", "c", "e")
|
||||
|
||||
count, up = list.Remove("b", 1)
|
||||
require.Equal(t, count, 1)
|
||||
require.Equal(t, int(up), 17)
|
||||
|
||||
res, _ = list.LPop(list.Length())
|
||||
require.Equal(t, res, []string{"a", "c", "c", "e"})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue