X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=codec%2Fmsg_codec_test.go;h=c950fd81c3ee9817b29e0806d9790b330b80384b;hb=c7ae74a95d1bd6fefcbb061f5f045c60c11e32fc;hp=cd1240e8724d93bea17ea052192ec1c73ae4fa68;hpb=0f731471ab258d9e01658f0ab70f8317fd0fb89c;p=govpp.git diff --git a/codec/msg_codec_test.go b/codec/msg_codec_test.go index cd1240e..c950fd8 100644 --- a/codec/msg_codec_test.go +++ b/codec/msg_codec_test.go @@ -1,10 +1,14 @@ -package codec +package codec_test import ( "bytes" + "git.fd.io/govpp.git/examples/binapi/ip_types" "testing" "git.fd.io/govpp.git/api" + "git.fd.io/govpp.git/codec" + "git.fd.io/govpp.git/examples/binapi/ip" + "git.fd.io/govpp.git/examples/binapi/vpe" ) type MyMsg struct { @@ -35,10 +39,41 @@ func TestEncode(t *testing.T) { msgID: 100, expData: []byte{0x00, 0x64, 0x00, 0x01, 0x41, 0x62, 0x63, 0x64, 0x65, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE8}, }, + {name: "show version", + msg: &vpe.ShowVersion{}, + msgID: 743, + expData: []byte{0x02, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + }, + {name: "ip route", + msg: &ip.IPRouteAddDel{ + IsAdd: true, + IsMultipath: true, + Route: ip.IPRoute{ + TableID: 0, + StatsIndex: 0, + Prefix: ip_types.Prefix{}, + NPaths: 0, + }, + }, + msgID: 743, + expData: []byte{0x02, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + }, + /*{name: "sr", + msg: &sr.SrPolicyAdd{ + BsidAddr: sr.IP6Address{}, + Weight: 0, + IsEncap: false, + IsSpray: false, + FibTable: 0, + Sids: sr.Srv6SidList{}, + }, + msgID: 99, + expData: []byte{0x00, 0x64, 0x00, 0x01, 0x41, 0x62, 0x63, 0x64, 0x65, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE8}, + },*/ } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - c := &MsgCodec{} + c := codec.DefaultCodec data, err := c.EncodeMsg(test.msg, test.msgID) if err != nil { @@ -52,7 +87,7 @@ func TestEncode(t *testing.T) { } func TestEncodePanic(t *testing.T) { - c := &MsgCodec{} + c := codec.DefaultCodec msg := &MyMsg{Index: 1, Label: []byte("thisIsLongerThan16Bytes"), Port: 1000}