MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestHashCollision

Function TestHashCollision

internal/ttlcache/utils_test.go:13–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestHashCollision(t *testing.T) {
14 var m = map[uint64]zero.Zero{}
15
16 var count = 1_000
17 if testutils.IsSingleTesting() {
18 count = 100_000_000
19 }
20
21 for i := 0; i < count; i++ {
22 var k = ttlcache.HashKeyString(strconv.Itoa(i))
23 _, ok := m[k]
24 if ok {
25 t.Fatal("collision at", i)
26 }
27 m[k] = zero.New()
28 }
29
30 t.Log(len(m), "elements")
31}
32
33func BenchmarkHashKey_Bytes(b *testing.B) {
34 runtime.GOMAXPROCS(1)

Callers

nothing calls this directly

Calls 4

IsSingleTestingFunction · 0.92
HashKeyStringFunction · 0.92
NewFunction · 0.92
LogMethod · 0.80

Tested by

no test coverage detected