From 84f1e917e78be7686e676f1d6cc0810ee499e561 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Sun, 5 Jul 2015 18:29:06 +0900 Subject: packet: fix bug of not taking care of withdrawn label Signed-off-by: ISHIDA Wataru --- packet/bgp_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'packet/bgp_test.go') diff --git a/packet/bgp_test.go b/packet/bgp_test.go index 84aaed75..286bd27c 100644 --- a/packet/bgp_test.go +++ b/packet/bgp_test.go @@ -360,3 +360,26 @@ func Test_ASLen(t *testing.T) { assert.Equal(0, as4path.ASLen()) } + +func Test_MPLSLabelStack(t *testing.T) { + assert := assert.New(t) + mpls := NewMPLSLabelStack() + buf, err := mpls.Serialize() + assert.Nil(err) + assert.Equal(true, bytes.Equal(buf, []byte{0, 0, 1})) + + mpls = &MPLSLabelStack{} + assert.Nil(mpls.DecodeFromBytes(buf)) + assert.Equal(1, len(mpls.Labels)) + assert.Equal(uint32(0), mpls.Labels[0]) + + mpls = NewMPLSLabelStack(WITHDRAW_LABEL) + buf, err = mpls.Serialize() + assert.Nil(err) + assert.Equal(true, bytes.Equal(buf, []byte{128, 0, 0})) + + mpls = &MPLSLabelStack{} + assert.Nil(mpls.DecodeFromBytes(buf)) + assert.Equal(1, len(mpls.Labels)) + assert.Equal(WITHDRAW_LABEL, mpls.Labels[0]) +} -- cgit v1.2.3