MCPcopy Create free account
hub / github.com/encodeous/nylon / TestCommonBits

Function TestCommonBits

polyamide/device/allowedips_test.go:21–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19}
20
21func TestCommonBits(t *testing.T) {
22 tests := []testPairCommonBits{
23 {s1: []byte{1, 4, 53, 128}, s2: []byte{0, 0, 0, 0}, match: 7},
24 {s1: []byte{0, 4, 53, 128}, s2: []byte{0, 0, 0, 0}, match: 13},
25 {s1: []byte{0, 4, 53, 253}, s2: []byte{0, 4, 53, 252}, match: 31},
26 {s1: []byte{192, 168, 1, 1}, s2: []byte{192, 169, 1, 1}, match: 15},
27 {s1: []byte{65, 168, 1, 1}, s2: []byte{192, 169, 1, 1}, match: 0},
28 }
29
30 for _, p := range tests {
31 v := commonBits(p.s1, p.s2)
32 if v != p.match {
33 t.Error(
34 "For slice", p.s1, p.s2,
35 "expected match", p.match,
36 ",but got", v,
37 )
38 }
39 }
40}
41
42func benchmarkTrie(peerNumber, addressNumber, _ int, b *testing.B) {
43 var trie *trieEntry

Callers

nothing calls this directly

Calls 2

commonBitsFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected