-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparameters_test.go
62 lines (58 loc) · 1.4 KB
/
parameters_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestDecodeOptionalParameters(t *testing.T) {
tests := []struct {
desc string
input []byte
want parameters
}{
{
desc: "All capabilities under a single capability field",
input: []byte{
0x02, 0x16, 0x01, 0x04, 0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x40, 0x02,
0x00, 0x78, 0x41, 0x04, 0x00, 0x00, 0xfc, 0x15, 0x46, 0x00, 0x47, 0x00,
},
want: parameters{
ASN32: [4]byte{0x00, 0x00, 0xfc, 0x15},
Refresh: true,
AddrFamilies: []addr{
addr{
AFI: 1,
SAFI: 1,
},
},
Supported: []uint8{1, 65, 70},
Unsupported: []uint8{2, 64, 71},
},
},
{
desc: "All capabilities under seperate capability fields",
// This has both 2 and 128 - route refresh and Cisco route refresh. Should I consider that refresh == 2 ?
input: []byte{
0x02, 0x06, 0x01, 0x04, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x80, 0x00,
0x02, 0x02, 0x02, 0x00,
},
want: parameters{
ASN32: [4]byte{0x00, 0x00, 0x00, 0x00},
Refresh: false,
AddrFamilies: []addr{
addr{
AFI: 1,
SAFI: 1,
},
},
Supported: []uint8{1},
Unsupported: []uint8{128, 2},
},
},
}
for _, test := range tests {
got := decodeOptionalParameters(&test.input)
if !cmp.Equal(got, test.want) {
t.Errorf("Test (%s): got %+v, want %+v", test.desc, got, test.want)
}
}
}