MCPcopy
hub / github.com/cornelk/hashmap / TestHashCollision

Function TestHashCollision

util_test.go:25–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23}
24
25func TestHashCollision(t *testing.T) {
26 m := New[string, int]()
27
28 staticHasher := func(key string) uintptr {
29 return 4 // chosen by fair dice roll. guaranteed to be random.
30 }
31
32 m.SetHasher(staticHasher)
33
34 inserted := m.Insert("1", 1)
35 assert.True(t, inserted)
36 inserted = m.Insert("2", 2)
37 assert.True(t, inserted)
38
39 value, ok := m.Get("1")
40 assert.True(t, ok)
41 assert.Equal(t, 1, value)
42
43 value, ok = m.Get("2")
44 assert.True(t, ok)
45 assert.Equal(t, 2, value)
46}
47
48func TestAliasTypeSupport(t *testing.T) {
49 type alias uintptr

Callers

nothing calls this directly

Calls 6

TrueFunction · 0.92
EqualFunction · 0.92
NewFunction · 0.85
SetHasherMethod · 0.80
InsertMethod · 0.80
GetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…