aboutsummaryrefslogtreecommitdiffstats
path: root/codec/marshaler_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'codec/marshaler_test.go')
-rw-r--r--codec/marshaler_test.go175
1 files changed, 1 insertions, 174 deletions
diff --git a/codec/marshaler_test.go b/codec/marshaler_test.go
index b3b20b0..985dd31 100644
--- a/codec/marshaler_test.go
+++ b/codec/marshaler_test.go
@@ -23,8 +23,7 @@ import (
"git.fd.io/govpp.git/binapi/ip_types"
"git.fd.io/govpp.git/binapi/sr"
"git.fd.io/govpp.git/codec"
- "git.fd.io/govpp.git/internal/testbinapi/binapi2001/interfaces"
- "git.fd.io/govpp.git/internal/testbinapi/binapi2001/ip"
+ interfaces "git.fd.io/govpp.git/internal/testbinapi/binapi2001/interface"
)
// CliInband represents VPP binary API message 'cli_inband'.
@@ -167,175 +166,3 @@ func TestNewCodecEncodeDecode2(t *testing.T) {
t.Fatalf("newData differs from oldData")
}
}
-
-func TestNewCodecEncode(t *testing.T) {
- m := NewIPRouteLookupReply()
- /*m := &sr.SrPoliciesDetails{
- Bsid: sr.IP6Address{00, 11, 22, 33, 44, 55, 66, 77, 88, 99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff},
- IsSpray: true,
- IsEncap: false,
- FibTable: 33,
- NumSidLists: 1,
- SidLists: []sr.Srv6SidList{
- {
- Weight: 555,
- NumSids: 2,
- Sids: [16]sr.IP6Address{
- {99},
- {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
- },
- },
- },
- }*/
-
- var err error
- var oldData, newData []byte
- {
- w := codec.Wrapper{m}
- size := m.Size()
- t.Logf("wrapper size: %d", size)
- oldData, err = w.Marshal(nil)
- if err != nil {
- t.Fatalf("expected nil error, got: %v", err)
- }
- }
- {
- size := m.Size()
- t.Logf("size: %d", size)
- newData, err = m.Marshal(nil)
- if err != nil {
- t.Fatalf("expected nil error, got: %v", err)
- }
- }
- t.Logf("Data:\nOLD[%d]: % 03x\nNEW[%d]: % 03x", len(oldData), oldData, len(newData), newData)
-
- if !bytes.Equal(oldData, newData) {
- t.Fatalf("newData differs from oldData")
- }
-}
-
-func TestNewCodecDecode(t *testing.T) {
- data := []byte{
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03,
- 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00,
- 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00,
- 0x00, 0x00, 0x08, 0x09, 0x0a, 0x00, 0x00, 0x00,
- 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x01, 0x09, 0x00,
- 0x00, 0x00, 0x08, 0x07, 0x06, 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,
- 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, 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, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- }
-
- var err error
- var oldData, newData ip.IPRouteAddDel
- {
- w := codec.Wrapper{&oldData}
- err = w.Unmarshal(data)
- if err != nil {
- t.Errorf("expected nil error, got: %v", err)
- }
- }
- {
- err = newData.Unmarshal(data)
- if err != nil {
- t.Errorf("expected nil error, got: %v", err)
- }
- }
- t.Logf("Data:\nOLD: %+v\nNEW: %+v", oldData, newData)
-
- if !reflect.DeepEqual(oldData, newData) {
- t.Fatalf("newData differs from oldData")
- }
-}
-
-func NewIPRouteLookupReply() *ip.IPRouteAddDel {
- return &ip.IPRouteAddDel{
- Route: ip.IPRoute{
- TableID: 3,
- StatsIndex: 5,
- Prefix: ip.Prefix{
- Address: ip.Address{
- Af: ip.ADDRESS_IP6,
- Un: ip.AddressUnion{},
- },
- Len: 24,
- },
- NPaths: 2,
- Paths: []ip.FibPath{
- {
- SwIfIndex: 5,
- TableID: 6,
- RpfID: 8,
- Weight: 9,
- Preference: 10,
- Type: 11,
- Flags: 1,
- Proto: 2,
- Nh: ip.FibPathNh{
- Address: ip.AddressUnion{},
- ViaLabel: 3,
- ObjID: 1,
- ClassifyTableIndex: 2,
- },
- NLabels: 1,
- LabelStack: [16]ip.FibMplsLabel{
- {
- IsUniform: 9,
- Label: 8,
- TTL: 7,
- Exp: 6,
- },
- },
- },
- {
- SwIfIndex: 7,
- TableID: 6,
- RpfID: 8,
- Weight: 9,
- Preference: 10,
- Type: 11,
- Flags: 1,
- Proto: 1,
- Nh: ip.FibPathNh{
- Address: ip.AddressUnion{},
- ViaLabel: 3,
- ObjID: 1,
- ClassifyTableIndex: 2,
- },
- NLabels: 2,
- LabelStack: [16]ip.FibMplsLabel{
- {
- IsUniform: 9,
- Label: 8,
- TTL: 7,
- Exp: 6,
- },
- {
- IsUniform: 10,
- Label: 8,
- TTL: 7,
- Exp: 6,
- },
- },
- },
- },
- },
- }
-}