7 "git.fd.io/govpp.git/api"
12 Label []byte `struc:"[16]byte"`
16 func (*MyMsg) GetMessageName() string {
19 func (*MyMsg) GetCrcString() string {
22 func (*MyMsg) GetMessageType() api.MessageType {
23 return api.OtherMessage
26 func TestEncode(t *testing.T) {
34 msg: &MyMsg{Index: 1, Label: []byte("Abcdef"), Port: 1000},
36 expData: []byte{0x00, 0x64, 0x00, 0x01, 0x41, 0x62, 0x63, 0x64, 0x65, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE8},
39 for _, test := range tests {
40 t.Run(test.name, func(t *testing.T) {
43 data, err := c.EncodeMsg(test.msg, test.msgID)
45 t.Fatalf("expected nil error, got: %v", err)
47 if !bytes.Equal(data, test.expData) {
48 t.Fatalf("expected data: % 0X, got: % 0X", test.expData, data)
54 func TestEncodePanic(t *testing.T) {
57 msg := &MyMsg{Index: 1, Label: []byte("thisIsLongerThan16Bytes"), Port: 1000}
59 _, err := c.EncodeMsg(msg, 100)
61 t.Fatalf("expected non-nil error, got: %v", err)