-
Notifications
You must be signed in to change notification settings - Fork 2
/
encoder_test.go
50 lines (48 loc) · 1.02 KB
/
encoder_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
package hdlc
import (
"reflect"
"testing"
)
func TestEncapsulate(t *testing.T) {
type args struct {
p []byte
hasAddressCtrlPrefix bool
}
tests := []struct {
name string
args args
want *Frame
}{
{
name: "real packet 1",
args: args{
p: []byte{0x08, 0x91},
hasAddressCtrlPrefix: false,
},
want: &Frame{
Payload: []byte{0x08, 0x91},
FCS: []byte{0x87, 0x44},
HasAddressCtrlPrefix: false,
},
},
{
name: "real packet 2",
args: args{
p: []byte{0x08, 0xb1},
hasAddressCtrlPrefix: false,
},
want: &Frame{
Payload: []byte{0x08, 0xb1},
FCS: []byte{0x85, 0x65},
HasAddressCtrlPrefix: false,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Encapsulate(tt.args.p, tt.args.hasAddressCtrlPrefix); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Encapsulate() = %v, want %v", got, tt.want)
}
})
}
}