feat!: Drop returns bool, Put doesn't stack-overflow (#21)
All checks were successful
CI / Check PR Title (push) Has been skipped
CI / Go Lint (push) Successful in 58s
CI / Makefile Lint (push) Successful in 55s
CI / Markdown Lint (push) Successful in 34s
CI / Unit Tests (push) Successful in 54s
CI / Fuzz Tests (push) Successful in 1m26s
CI / Mutation Tests (push) Successful in 1m11s

## Description

Closes #11.

## Changes

### Design Decisions

## Checklist

- [ ] Tests pass
- [ ] Docs updated

Reviewed-on: #21
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
This commit was merged in pull request #21.
This commit is contained in:
2026-04-17 01:31:01 +00:00
committed by Maxim Hutz
parent 29ba6bfd4d
commit 39548b4332
6 changed files with 107 additions and 65 deletions

View File

@@ -124,9 +124,9 @@ func TestDropExistingItem(t *testing.T) {
table := cuckoo.New[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.New[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())
}