From 7ce1a55d0e2ab0ed355bbe57c4dc20a97ac8b10a Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Sat, 23 Oct 2021 15:18:10 +0800 Subject: [PATCH] test(listx): add listx remove --- pkg/structure/listx/listx_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/structure/listx/listx_test.go b/pkg/structure/listx/listx_test.go index bc34617..b1feaa1 100644 --- a/pkg/structure/listx/listx_test.go +++ b/pkg/structure/listx/listx_test.go @@ -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"}) +}