summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table/destination_test.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2019-10-25 20:33:59 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-10-25 20:38:33 +0900
commitb4e2d9e440a4eb6d3091a7c586d2e55b69ec968a (patch)
tree68af74b393dda96a33d47a995b8c3f12680e51e2 /internal/pkg/table/destination_test.go
parent6e81f596b1e924337470417cf1e3faa3260308da (diff)
table: replace radix with crit-bit algo for longer-prefixes search
faster and less memory usage. Now go-radix has gone. Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'internal/pkg/table/destination_test.go')
-rw-r--r--internal/pkg/table/destination_test.go31
1 files changed, 1 insertions, 30 deletions
diff --git a/internal/pkg/table/destination_test.go b/internal/pkg/table/destination_test.go
index 110278fb..b1c1b2e8 100644
--- a/internal/pkg/table/destination_test.go
+++ b/internal/pkg/table/destination_test.go
@@ -17,7 +17,7 @@ package table
import (
//"fmt"
- "fmt"
+
"net"
"testing"
"time"
@@ -292,35 +292,6 @@ func updateMsgD3() *bgp.BGPMessage {
return updateMsg
}
-func TestRadixkey(t *testing.T) {
- assert.Equal(t, "000010100000001100100000", CidrToRadixkey("10.3.32.0/24"))
- assert.Equal(t, "000010100000001100100000", IpToRadixkey(net.ParseIP("10.3.32.0").To4(), 24))
- assert.Equal(t, "000010100000001100100000", IpToRadixkey(net.ParseIP("10.3.32.0").To4(), 24))
- assert.Equal(t, CidrToRadixkey("::ffff:0.0.0.0/96")+"000010100000001100100000", CidrToRadixkey("::ffff:10.3.32.0/120"))
-}
-
-func TestIpToRadixkey(t *testing.T) {
- for i := byte(0); i < 255; i += 3 {
- for y := byte(1); y < 128; y *= 2 {
- ip := net.IPv4(i, i+2, i+3, i-y)
- for n := uint8(16); n <= 32; n += 2 {
- exp := CidrToRadixkey(fmt.Sprintf("%v/%d", ip.To4(), n))
- got := IpToRadixkey(ip.To4(), n)
- if exp != got {
- t.Fatalf(`exp %v; got %v`, exp, got)
- }
- }
- for n := uint8(116); n <= 128; n += 2 {
- exp := CidrToRadixkey(fmt.Sprintf("::ffff:%v/%d", ip.To16(), n))
- got := IpToRadixkey(ip.To16(), n)
- if exp != got {
- t.Fatalf(`exp %v; got %v`, exp, got)
- }
- }
- }
- }
-}
-
func TestMultipath(t *testing.T) {
UseMultiplePaths.Enabled = true
origin := bgp.NewPathAttributeOrigin(0)