diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-05 18:29:06 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-07-05 23:44:22 +0900 |
commit | 84f1e917e78be7686e676f1d6cc0810ee499e561 (patch) | |
tree | f014a79f80b923b78b0065ee470efbe9c934e191 /packet/bgp_test.go | |
parent | 2fc9b887fc63da94e173f75dd15330254e35647c (diff) |
packet: fix bug of not taking care of withdrawn label
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp_test.go')
-rw-r--r-- | packet/bgp_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
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]) +} |