From 7fd9a94922e120e449b5e23ef69b886632631825 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Tue, 22 Mar 2022 14:36:35 +0800 Subject: [PATCH] fix: fix lint warning 'ineffassign' --- datastructure/link/doublylink_test.go | 11 ++++------- datastructure/link/singlylink_test.go | 8 ++++---- datastructure/list/list_test.go | 4 ++-- datastructure/queue/linkedqueue_test.go | 8 ++++---- datastructure/stack/arraystack_test.go | 8 ++++---- datastructure/stack/linkedstack_test.go | 8 ++++---- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/datastructure/link/doublylink_test.go b/datastructure/link/doublylink_test.go index fb9b010..83998ff 100644 --- a/datastructure/link/doublylink_test.go +++ b/datastructure/link/doublylink_test.go @@ -44,14 +44,11 @@ func TestDoublyLink_InsertAt(t *testing.T) { err := link.InsertAt(1, 1) assert.IsNotNil(err) - err = link.InsertAt(0, 1) - err = link.InsertAt(1, 2) - err = link.InsertAt(2, 4) - err = link.InsertAt(2, 3) + link.InsertAt(0, 1) + link.InsertAt(1, 2) + link.InsertAt(2, 4) + link.InsertAt(2, 3) - if err != nil { - t.FailNow() - } link.Print() expected := []int{1, 2, 3, 4} diff --git a/datastructure/link/singlylink_test.go b/datastructure/link/singlylink_test.go index 26431ca..9227515 100644 --- a/datastructure/link/singlylink_test.go +++ b/datastructure/link/singlylink_test.go @@ -44,10 +44,10 @@ func TestSinglyLink_InsertAt(t *testing.T) { err := link.InsertAt(1, 1) assert.IsNotNil(err) - err = link.InsertAt(0, 1) - err = link.InsertAt(1, 2) - err = link.InsertAt(2, 4) - err = link.InsertAt(2, 3) + link.InsertAt(0, 1) + link.InsertAt(1, 2) + link.InsertAt(2, 4) + link.InsertAt(2, 3) if err != nil { t.FailNow() diff --git a/datastructure/list/list_test.go b/datastructure/list/list_test.go index 984c622..0920e58 100644 --- a/datastructure/list/list_test.go +++ b/datastructure/list/list_test.go @@ -99,7 +99,7 @@ func TestPopFirst(t *testing.T) { assert.Equal([]int{2, 3}, list.Data()) list2 := NewList([]int{}) - v, ok = list2.PopFirst() + _, ok = list2.PopFirst() assert.Equal(false, ok) assert.Equal([]int{}, list2.Data()) } @@ -114,7 +114,7 @@ func TestPopLast(t *testing.T) { assert.Equal([]int{1, 2}, list.Data()) list2 := NewList([]int{}) - v, ok = list2.PopLast() + _, ok = list2.PopLast() assert.Equal(false, ok) assert.Equal([]int{}, list2.Data()) } diff --git a/datastructure/queue/linkedqueue_test.go b/datastructure/queue/linkedqueue_test.go index 8a238d4..2bf9844 100644 --- a/datastructure/queue/linkedqueue_test.go +++ b/datastructure/queue/linkedqueue_test.go @@ -40,14 +40,14 @@ func TestLinkedQueue_Front(t *testing.T) { assert := internal.NewAssert(t, "TestLinkedQueue_Front") queue := NewLinkedQueue[int]() - val, err := queue.Front() + _, err := queue.Front() assert.IsNotNil(err) queue.EnQueue(1) queue.EnQueue(2) queue.EnQueue(3) - val, err = queue.Front() + val, err := queue.Front() assert.Equal(1, *val) assert.IsNil(err) } @@ -56,14 +56,14 @@ func TestLinkedQueue_Back(t *testing.T) { assert := internal.NewAssert(t, "TestLinkedQueue_Back") queue := NewLinkedQueue[int]() - val, err := queue.Back() + _, err := queue.Back() assert.IsNotNil(err) queue.EnQueue(1) queue.EnQueue(2) queue.EnQueue(3) - val, err = queue.Back() + val, err := queue.Back() assert.Equal(3, *val) assert.IsNil(err) } diff --git a/datastructure/stack/arraystack_test.go b/datastructure/stack/arraystack_test.go index 59452f0..7fca175 100644 --- a/datastructure/stack/arraystack_test.go +++ b/datastructure/stack/arraystack_test.go @@ -26,14 +26,14 @@ func TestArrayStack_Pop(t *testing.T) { assert := internal.NewAssert(t, "TestArrayStack_Pop") stack := NewArrayStack[int]() - topItem, err := stack.Pop() + _, err := stack.Pop() assert.IsNotNil(err) stack.Push(1) stack.Push(2) stack.Push(3) - topItem, err = stack.Pop() + topItem, err := stack.Pop() assert.IsNil(err) assert.Equal(3, *topItem) @@ -45,14 +45,14 @@ func TestArrayStack_Peak(t *testing.T) { assert := internal.NewAssert(t, "TestArrayStack_Peak") stack := NewArrayStack[int]() - topItem, err := stack.Peak() + _, err := stack.Peak() assert.IsNotNil(err) stack.Push(1) stack.Push(2) stack.Push(3) - topItem, err = stack.Peak() + topItem, err := stack.Peak() assert.IsNil(err) assert.Equal(3, *topItem) diff --git a/datastructure/stack/linkedstack_test.go b/datastructure/stack/linkedstack_test.go index 65e3b82..a067d2f 100644 --- a/datastructure/stack/linkedstack_test.go +++ b/datastructure/stack/linkedstack_test.go @@ -28,14 +28,14 @@ func TestLinkedStack_Pop(t *testing.T) { assert := internal.NewAssert(t, "TestLinkedStack_Pop") stack := NewLinkedStack[int]() - topItem, err := stack.Pop() + _, err := stack.Pop() assert.IsNotNil(err) stack.Push(1) stack.Push(2) stack.Push(3) - topItem, err = stack.Pop() + topItem, err := stack.Pop() assert.IsNil(err) assert.Equal(3, *topItem) @@ -48,14 +48,14 @@ func TestLinkedStack_Peak(t *testing.T) { assert := internal.NewAssert(t, "TestLinkedStack_Peak") stack := NewLinkedStack[int]() - topItem, err := stack.Peak() + _, err := stack.Peak() assert.IsNotNil(err) stack.Push(1) stack.Push(2) stack.Push(3) - topItem, err = stack.Peak() + topItem, err := stack.Peak() assert.IsNil(err) assert.Equal(3, *topItem)