diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-06-02 18:02:04 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-06-02 18:02:04 +0200 |
commit | dbc3ee3e9dc50e01dab9ae789a44f90502542335 (patch) | |
tree | 549b421d2f634c9bb6cde5f2f4d4d645e15cdde5 /src | |
parent | a377bcaed7e97dba2ef953e995abb5272396dc2f (diff) |
Trie random test
Test trie against naive implementation of prefix routing.
Diffstat (limited to 'src')
-rw-r--r-- | src/trie_rand_test.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/trie_rand_test.go b/src/trie_rand_test.go index f8b860c..840d269 100644 --- a/src/trie_rand_test.go +++ b/src/trie_rand_test.go @@ -12,7 +12,13 @@ const ( NumberOfTests = 10000 ) -type SlowRouter []*Trie +type SlowNode struct { + peer *Peer + cidr uint + bits []byte +} + +type SlowRouter []*SlowNode func (r SlowRouter) Len() int { return len(r) @@ -34,7 +40,7 @@ func (r SlowRouter) Insert(addr []byte, cidr uint, peer *Peer) SlowRouter { return r } } - r = append(r, &Trie{ + r = append(r, &SlowNode{ cidr: cidr, bits: addr, peer: peer, @@ -81,7 +87,7 @@ func TestTrieRandomIPv4(t *testing.T) { peer1 := slow.Lookup(addr[:]) peer2 := trie.Lookup(addr[:]) if peer1 != peer2 { - t.Error("Trie did not match niave implementation, for:", addr) + t.Error("Trie did not match naive implementation, for:", addr) } } } @@ -114,7 +120,7 @@ func TestTrieRandomIPv6(t *testing.T) { peer1 := slow.Lookup(addr[:]) peer2 := trie.Lookup(addr[:]) if peer1 != peer2 { - t.Error("Trie did not match niave implementation, for:", addr) + t.Error("Trie did not match naive implementation, for:", addr) } } } |