feat: 100% mutation test coverage
All checks were successful
All checks were successful
- Fixed mutation coverage to be 1.0, instead of 100.
This commit is contained in:
@@ -6,4 +6,4 @@ unleash:
|
|||||||
workers: 4
|
workers: 4
|
||||||
dry-run: false
|
dry-run: false
|
||||||
threshold:
|
threshold:
|
||||||
efficacy: 100
|
efficacy: 1.0
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package cuckoo_test
|
package cuckoo_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"maps"
|
"maps"
|
||||||
"math/rand/v2"
|
"math/rand/v2"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -153,3 +154,88 @@ func TestDropNoItem(t *testing.T) {
|
|||||||
assert.Equal(0, table.Size())
|
assert.Equal(0, table.Size())
|
||||||
assert.False(table.Has(key))
|
assert.False(table.Has(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDropItemCapacity(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
key := 0
|
||||||
|
table := cuckoo.NewTable[int, bool](
|
||||||
|
cuckoo.Capacity(64),
|
||||||
|
cuckoo.GrowthFactor(2),
|
||||||
|
)
|
||||||
|
|
||||||
|
startingCapacity := table.TotalCapacity()
|
||||||
|
err := table.Drop(key)
|
||||||
|
endingCapacity := table.TotalCapacity()
|
||||||
|
|
||||||
|
assert.NoError(err)
|
||||||
|
assert.Equal(0, table.Size())
|
||||||
|
assert.Equal(uint64(128), startingCapacity)
|
||||||
|
assert.Equal(uint64(64), endingCapacity)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPutNoCapacity(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
key, value := 0, true
|
||||||
|
table := cuckoo.NewTable[int, bool](
|
||||||
|
cuckoo.Capacity(0),
|
||||||
|
)
|
||||||
|
|
||||||
|
err := table.Put(key, value)
|
||||||
|
|
||||||
|
assert.NoError(err)
|
||||||
|
assert.Equal(1, table.Size())
|
||||||
|
assert.True(table.Has(key))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBadHashCapacity(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
table := cuckoo.NewCustomTable[int, bool](
|
||||||
|
func(int) uint64 { return 0 },
|
||||||
|
func(int) uint64 { return 0 },
|
||||||
|
func(a, b int) bool { return a == b },
|
||||||
|
cuckoo.Capacity(20),
|
||||||
|
)
|
||||||
|
|
||||||
|
err1 := table.Put(0, true)
|
||||||
|
err2 := table.Put(1, true)
|
||||||
|
err3 := table.Put(2, true)
|
||||||
|
|
||||||
|
assert.NoError(err1)
|
||||||
|
assert.NoError(err2)
|
||||||
|
assert.Error(err3)
|
||||||
|
|
||||||
|
assert.Equal(uint64(80), table.TotalCapacity())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDropResizeCapacity(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
table := cuckoo.NewTable[int, bool](
|
||||||
|
cuckoo.Capacity(10),
|
||||||
|
)
|
||||||
|
|
||||||
|
err1 := table.Put(0, true)
|
||||||
|
err2 := table.Put(1, true)
|
||||||
|
err3 := table.Drop(1)
|
||||||
|
|
||||||
|
assert.NoError(errors.Join(err1, err2, err3))
|
||||||
|
assert.Equal(uint64(20), table.TotalCapacity())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewTableBy(t *testing.T) {
|
||||||
|
type User struct {
|
||||||
|
_ func()
|
||||||
|
id string
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
assert := assert.New(t)
|
||||||
|
table := cuckoo.NewTableBy[User, bool](
|
||||||
|
func(u User) string { return u.id },
|
||||||
|
)
|
||||||
|
|
||||||
|
err := table.Put(User{nil, "1", "Robert"}, true)
|
||||||
|
|
||||||
|
assert.NoError(err)
|
||||||
|
assert.Equal(1, table.Size())
|
||||||
|
assert.True(table.Has(User{nil, "1", "Robbie"}))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user