fix: tests were out of date
All checks were successful
CI / Check PR Title (pull_request) Successful in 32s
CI / Go Lint (pull_request) Successful in 54s
CI / Markdown Lint (pull_request) Successful in 34s
CI / Makefile Lint (pull_request) Successful in 54s
CI / Unit Tests (pull_request) Successful in 54s
CI / Fuzz Tests (pull_request) Successful in 1m25s
CI / Mutation Tests (pull_request) Successful in 1m8s

This commit is contained in:
2026-04-16 21:12:39 -04:00
parent 24df23218c
commit b395d6e1f4
4 changed files with 18 additions and 18 deletions

View File

@@ -77,7 +77,7 @@ func FuzzInsertLookup(f *testing.F) {
_, ok = actual.Get(step.key) _, ok = actual.Get(step.key)
assert.False(ok) assert.False(ok)
} else { } else {
_, err := actual.Put(step.key, step.value) err := actual.Put(step.key, step.value)
assert.NoError(err) assert.NoError(err)
expected[step.key] = step.value expected[step.key] = step.value

View File

@@ -23,7 +23,7 @@ func TestLoad(t *testing.T) {
table := New[int, bool](Capacity(8)) table := New[int, bool](Capacity(8))
for i := range 16 { for i := range 16 {
_, err := table.Put(i, true) err := table.Put(i, true)
assert.NoError(err) assert.NoError(err)
assert.Equal(float64(table.Size())/float64(table.TotalCapacity()), table.load()) assert.Equal(float64(table.Size())/float64(table.TotalCapacity()), table.load())
} }

View File

@@ -25,7 +25,7 @@ func TestAddItem(t *testing.T) {
key, value := 0, true key, value := 0, true
table := cuckoo.New[int, bool]() table := cuckoo.New[int, bool]()
_, err := table.Put(key, value) err := table.Put(key, value)
assert.NoError(err) assert.NoError(err)
assert.Equal(1, table.Size()) assert.Equal(1, table.Size())
@@ -38,7 +38,7 @@ func TestPutOverwrite(t *testing.T) {
table := cuckoo.New[int, int]() table := cuckoo.New[int, int]()
(table.Put(key, value)) (table.Put(key, value))
_, err := table.Put(key, newValue) err := table.Put(key, newValue)
assert.NoError(err) assert.NoError(err)
assert.Equal(1, table.Size()) assert.Equal(1, table.Size())
@@ -52,9 +52,9 @@ func TestSameHash(t *testing.T) {
hash := func(int) uint64 { return 0 } hash := func(int) uint64 { return 0 }
table := cuckoo.NewCustom[int, bool](hash, hash, cuckoo.DefaultEqualFunc[int]) table := cuckoo.NewCustom[int, bool](hash, hash, cuckoo.DefaultEqualFunc[int])
_, errA := table.Put(0, true) errA := table.Put(0, true)
_, errB := table.Put(1, true) errB := table.Put(1, true)
_, errC := table.Put(2, true) errC := table.Put(2, true)
assert.NoError(errA) assert.NoError(errA)
assert.NoError(errB) assert.NoError(errB)
@@ -76,7 +76,7 @@ func TestResizeCapacity(t *testing.T) {
) )
for table.TotalCapacity() == 16 { for table.TotalCapacity() == 16 {
_, err := table.Put(rand.Int(), true) err := table.Put(rand.Int(), true)
assert.NoError(err) assert.NoError(err)
} }
@@ -89,7 +89,7 @@ func TestPutMany(t *testing.T) {
for i := range 1_000 { for i := range 1_000 {
expected[i] = true expected[i] = true
_, err := actual.Put(i, true) err := actual.Put(i, true)
assert.NoError(err) assert.NoError(err)
} }
@@ -103,7 +103,7 @@ func TestGetMany(t *testing.T) {
table := cuckoo.New[int, bool]() table := cuckoo.New[int, bool]()
for i := range 1_000 { for i := range 1_000 {
_, err := table.Put(i, true) err := table.Put(i, true)
assert.NoError(err) assert.NoError(err)
} }
@@ -167,7 +167,7 @@ func TestPutNoCapacity(t *testing.T) {
cuckoo.Capacity(0), cuckoo.Capacity(0),
) )
_, err := table.Put(key, value) err := table.Put(key, value)
assert.NoError(err) assert.NoError(err)
assert.Equal(1, table.Size()) assert.Equal(1, table.Size())
@@ -183,9 +183,9 @@ func TestBadHashCapacity(t *testing.T) {
cuckoo.Capacity(20), cuckoo.Capacity(20),
) )
_, err1 := table.Put(0, true) err1 := table.Put(0, true)
_, err2 := table.Put(1, true) err2 := table.Put(1, true)
_, err3 := table.Put(2, true) err3 := table.Put(2, true)
assert.NoError(err1) assert.NoError(err1)
assert.NoError(err2) assert.NoError(err2)
@@ -200,8 +200,8 @@ func TestDropResizeCapacity(t *testing.T) {
cuckoo.Capacity(10), cuckoo.Capacity(10),
) )
_, err1 := table.Put(0, true) err1 := table.Put(0, true)
_, err2 := table.Put(1, true) err2 := table.Put(1, true)
table.Drop(1) table.Drop(1)
assert.NoError(errors.Join(err1, err2)) assert.NoError(errors.Join(err1, err2))
@@ -218,7 +218,7 @@ func TestNewTableBy(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
table := cuckoo.NewBy[User, bool](func(u User) string { return u.id }) table := cuckoo.NewBy[User, bool](func(u User) string { return u.id })
_, err := table.Put(User{nil, "1", "Robert"}, true) err := table.Put(User{nil, "1", "Robert"}, true)
assert.NoError(err) assert.NoError(err)
assert.Equal(1, table.Size()) assert.Equal(1, table.Size())

View File

@@ -10,7 +10,7 @@ import (
func Example_basic() { func Example_basic() {
table := cuckoo.New[int, string]() table := cuckoo.New[int, string]()
if _, err := table.Put(1, "Hello, World!"); err != nil { if err := table.Put(1, "Hello, World!"); err != nil {
fmt.Println("Put error:", err) fmt.Println("Put error:", err)
} }