Skip to content

Commit

Permalink
fix golang lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dxyinme committed May 6, 2024
1 parent 1845af0 commit 018df69
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions internal/tree/red_black_tree_iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ func TestIteratorFind(t *testing.T) {
t.Run("查找存在的节点", func(t *testing.T) {
t.Parallel()
rbt := NewRBTree[int, int](ekit.ComparatorRealNumber[int])
rbt.Add(1, 101)
rbt.Add(-100, 102)
rbt.Add(100, 103)
assert.Nil(t, rbt.Add(1, 101))
assert.Nil(t, rbt.Add(-100, 102))
assert.Nil(t, rbt.Add(100, 103))
it, err := rbt.FindIt(-100)
assert.Nil(t, err)
assert.Equal(t, 102, it.Get().Value)
Expand All @@ -58,9 +58,9 @@ func TestIteratorFind(t *testing.T) {
t.Run("查找不存在的节点", func(t *testing.T) {
t.Parallel()
rbt := NewRBTree[int, int](ekit.ComparatorRealNumber[int])
rbt.Add(1, 101)
rbt.Add(-100, 102)
rbt.Add(100, 103)
assert.Nil(t, rbt.Add(1, 101))
assert.Nil(t, rbt.Add(-100, 102))
assert.Nil(t, rbt.Add(100, 103))
it, err := rbt.FindIt(2)
assert.Equal(t, ErrRBTreeNotRBNode, err)
assert.Nil(t, it)
Expand All @@ -69,9 +69,9 @@ func TestIteratorFind(t *testing.T) {
t.Run("查找存在的节点,删除后不存在", func(t *testing.T) {
t.Parallel()
rbt := NewRBTree[int, int](ekit.ComparatorRealNumber[int])
rbt.Add(1, 101)
rbt.Add(-100, 102)
rbt.Add(100, 103)
assert.Nil(t, rbt.Add(1, 101))
assert.Nil(t, rbt.Add(-100, 102))
assert.Nil(t, rbt.Add(100, 103))
it, err := rbt.FindIt(-100)
assert.Nil(t, err)
assert.Equal(t, 102, it.Get().Value)
Expand All @@ -84,9 +84,9 @@ func TestIteratorFind(t *testing.T) {
t.Run("查找不存在的节点,增加后存在", func(t *testing.T) {
t.Parallel()
rbt := NewRBTree[int, int](ekit.ComparatorRealNumber[int])
rbt.Add(1, 101)
rbt.Add(-100, 102)
rbt.Add(100, 103)
assert.Nil(t, rbt.Add(1, 101))
assert.Nil(t, rbt.Add(-100, 102))
assert.Nil(t, rbt.Add(100, 103))
it, err := rbt.FindIt(2)
assert.Equal(t, ErrRBTreeNotRBNode, err)
assert.Nil(t, it)
Expand All @@ -101,17 +101,17 @@ func TestIteratorDelete(t *testing.T) {
t.Run("删除不存在的节点", func(t *testing.T) {
t.Parallel()
rbt := NewRBTree[int, int](ekit.ComparatorRealNumber[int])
rbt.Add(1, 101)
rbt.Add(-100, 102)
rbt.Add(100, 103)
assert.Nil(t, rbt.Add(1, 101))
assert.Nil(t, rbt.Add(-100, 102))
assert.Nil(t, rbt.Add(100, 103))
assert.Equal(t, ErrRBTreeIteratorInvalid, rbt.DeleteIt(nil))
})
t.Run("重复删除某个节点", func(t *testing.T) {
t.Parallel()
rbt := NewRBTree[int, int](ekit.ComparatorRealNumber[int])
rbt.Add(1, 101)
rbt.Add(-100, 102)
rbt.Add(100, 103)
assert.Nil(t, rbt.Add(1, 101))
assert.Nil(t, rbt.Add(-100, 102))
assert.Nil(t, rbt.Add(100, 103))
it, err := rbt.FindIt(-100)
assert.Nil(t, err)
assert.Equal(t, nil, rbt.DeleteIt(it))
Expand Down

0 comments on commit 018df69

Please sign in to comment.