feat: drop item returns bool, whether item existed
This commit is contained in:
@@ -124,9 +124,9 @@ func TestDropExistingItem(t *testing.T) {
|
||||
table := cuckoo.NewTable[int, bool]()
|
||||
(table.Put(key, value))
|
||||
|
||||
err := table.Drop(key)
|
||||
had := table.Drop(key)
|
||||
|
||||
assert.NoError(err)
|
||||
assert.True(had)
|
||||
assert.Equal(0, table.Size())
|
||||
assert.False(table.Has(key))
|
||||
}
|
||||
@@ -136,9 +136,9 @@ func TestDropNoItem(t *testing.T) {
|
||||
key := 0
|
||||
table := cuckoo.NewTable[int, bool]()
|
||||
|
||||
err := table.Drop(key)
|
||||
had := table.Drop(key)
|
||||
|
||||
assert.NoError(err)
|
||||
assert.False(had)
|
||||
assert.Equal(0, table.Size())
|
||||
assert.False(table.Has(key))
|
||||
}
|
||||
@@ -152,10 +152,9 @@ func TestDropItemCapacity(t *testing.T) {
|
||||
)
|
||||
|
||||
startingCapacity := table.TotalCapacity()
|
||||
err := table.Drop(key)
|
||||
table.Drop(key)
|
||||
endingCapacity := table.TotalCapacity()
|
||||
|
||||
assert.NoError(err)
|
||||
assert.Equal(0, table.Size())
|
||||
assert.Equal(uint64(128), startingCapacity)
|
||||
assert.Equal(uint64(64), endingCapacity)
|
||||
@@ -203,9 +202,9 @@ func TestDropResizeCapacity(t *testing.T) {
|
||||
|
||||
_, err1 := table.Put(0, true)
|
||||
_, err2 := table.Put(1, true)
|
||||
err3 := table.Drop(1)
|
||||
table.Drop(1)
|
||||
|
||||
assert.NoError(errors.Join(err1, err2, err3))
|
||||
assert.NoError(errors.Join(err1, err2))
|
||||
assert.Equal(uint64(20), table.TotalCapacity())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user