diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-02-15 11:53:56 +0900 |
---|---|---|
committer | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-02-15 11:53:56 +0900 |
commit | 4e1edd39c2333af217d8972ad8c1b7b0556c93cc (patch) | |
tree | 64c2b0d6e1aca786d9921e640111ccf1007da9dc | |
parent | 9f6a0c501af7375a2c242869e249f72bc6ed5770 (diff) |
test: not rely on the type check auto conversion in assert.Equal
-rw-r--r-- | packet/validate_test.go | 30 | ||||
-rw-r--r-- | server/fsm_test.go | 12 |
2 files changed, 21 insertions, 21 deletions
diff --git a/packet/validate_test.go b/packet/validate_test.go index 7f5d93ec..effd9d89 100644 --- a/packet/validate_test.go +++ b/packet/validate_test.go @@ -155,8 +155,8 @@ func Test_Validate_duplicate_attribute(t *testing.T) { assert.Equal(false, res) assert.Error(err) e := err.(*MessageError) - assert.Equal(BGP_ERROR_UPDATE_MESSAGE_ERROR, e.TypeCode) - assert.Equal(BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST, e.SubTypeCode) + assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode) + assert.Equal(uint8(BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST), e.SubTypeCode) assert.Nil(e.Data) } @@ -168,10 +168,10 @@ func Test_Validate_mandatory_missing(t *testing.T) { assert.Equal(false, res) assert.Error(err) e := err.(*MessageError) - assert.Equal(BGP_ERROR_UPDATE_MESSAGE_ERROR, e.TypeCode) - assert.Equal(BGP_ERROR_SUB_MISSING_WELL_KNOWN_ATTRIBUTE, e.SubTypeCode) + assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode) + assert.Equal(uint8(BGP_ERROR_SUB_MISSING_WELL_KNOWN_ATTRIBUTE), e.SubTypeCode) missing, _ := binary.Uvarint(e.Data) - assert.Equal(1, missing) + assert.Equal(uint8(1), missing) } func Test_Validate_mandatory_missing_nocheck(t *testing.T) { @@ -198,8 +198,8 @@ func Test_Validate_invalid_origin(t *testing.T) { assert.Equal(false, res) assert.Error(err) e := err.(*MessageError) - assert.Equal(BGP_ERROR_UPDATE_MESSAGE_ERROR, e.TypeCode) - assert.Equal(BGP_ERROR_SUB_INVALID_ORIGIN_ATTRIBUTE, e.SubTypeCode) + assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode) + assert.Equal(uint8(BGP_ERROR_SUB_INVALID_ORIGIN_ATTRIBUTE), e.SubTypeCode) assert.Equal(originBytes, e.Data) } @@ -219,8 +219,8 @@ func Test_Validate_invalid_nexthop_zero(t *testing.T) { assert.Equal(false, res) assert.Error(err) e := err.(*MessageError) - assert.Equal(BGP_ERROR_UPDATE_MESSAGE_ERROR, e.TypeCode) - assert.Equal(BGP_ERROR_SUB_INVALID_NEXT_HOP_ATTRIBUTE, e.SubTypeCode) + assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode) + assert.Equal(uint8(BGP_ERROR_SUB_INVALID_NEXT_HOP_ATTRIBUTE), e.SubTypeCode) assert.Equal(nexthopBytes, e.Data) } @@ -240,8 +240,8 @@ func Test_Validate_invalid_nexthop_lo(t *testing.T) { assert.Equal(false, res) assert.Error(err) e := err.(*MessageError) - assert.Equal(BGP_ERROR_UPDATE_MESSAGE_ERROR, e.TypeCode) - assert.Equal(BGP_ERROR_SUB_INVALID_NEXT_HOP_ATTRIBUTE, e.SubTypeCode) + assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode) + assert.Equal(uint8(BGP_ERROR_SUB_INVALID_NEXT_HOP_ATTRIBUTE), e.SubTypeCode) assert.Equal(nexthopBytes, e.Data) } @@ -261,8 +261,8 @@ func Test_Validate_invalid_nexthop_de(t *testing.T) { assert.Equal(false, res) assert.Error(err) e := err.(*MessageError) - assert.Equal(BGP_ERROR_UPDATE_MESSAGE_ERROR, e.TypeCode) - assert.Equal(BGP_ERROR_SUB_INVALID_NEXT_HOP_ATTRIBUTE, e.SubTypeCode) + assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode) + assert.Equal(uint8(BGP_ERROR_SUB_INVALID_NEXT_HOP_ATTRIBUTE), e.SubTypeCode) assert.Equal(nexthopBytes, e.Data) } @@ -281,7 +281,7 @@ func Test_Validate_unrecognized_well_known(t *testing.T) { assert.Equal(false, res) assert.Error(err) e := err.(*MessageError) - assert.Equal(BGP_ERROR_UPDATE_MESSAGE_ERROR, e.TypeCode) - assert.Equal(BGP_ERROR_SUB_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE, e.SubTypeCode) + assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode) + assert.Equal(uint8(BGP_ERROR_SUB_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE), e.SubTypeCode) assert.Equal(unknownBytes, e.Data) } diff --git a/server/fsm_test.go b/server/fsm_test.go index 5a1feafa..ae31cc5a 100644 --- a/server/fsm_test.go +++ b/server/fsm_test.go @@ -145,8 +145,8 @@ func TestFSMHandlerOpensent_HoldTimerExpired(t *testing.T) { assert.Equal(bgp.BGP_FSM_IDLE, state) lastMsg := m.sendBuf[len(m.sendBuf)-1] sent, _ := bgp.ParseBGPMessage(lastMsg) - assert.Equal(bgp.BGP_MSG_NOTIFICATION, sent.Header.Type) - assert.Equal(bgp.BGP_ERROR_HOLD_TIMER_EXPIRED, sent.Body.(*bgp.BGPNotification).ErrorCode) + assert.Equal(uint8(bgp.BGP_MSG_NOTIFICATION), sent.Header.Type) + assert.Equal(uint8(bgp.BGP_ERROR_HOLD_TIMER_EXPIRED), sent.Body.(*bgp.BGPNotification).ErrorCode) } @@ -169,8 +169,8 @@ func TestFSMHandlerOpenconfirm_HoldTimerExpired(t *testing.T) { assert.Equal(bgp.BGP_FSM_IDLE, state) lastMsg := m.sendBuf[len(m.sendBuf)-1] sent, _ := bgp.ParseBGPMessage(lastMsg) - assert.Equal(bgp.BGP_MSG_NOTIFICATION, sent.Header.Type) - assert.Equal(bgp.BGP_ERROR_HOLD_TIMER_EXPIRED, sent.Body.(*bgp.BGPNotification).ErrorCode) + assert.Equal(uint8(bgp.BGP_MSG_NOTIFICATION), sent.Header.Type) + assert.Equal(uint8(bgp.BGP_ERROR_HOLD_TIMER_EXPIRED), sent.Body.(*bgp.BGPNotification).ErrorCode) } @@ -207,8 +207,8 @@ func TestFSMHandlerEstablish_HoldTimerExpired(t *testing.T) { assert.Equal(bgp.BGP_FSM_IDLE, state) lastMsg := m.sendBuf[len(m.sendBuf)-1] sent, _ := bgp.ParseBGPMessage(lastMsg) - assert.Equal(bgp.BGP_MSG_NOTIFICATION, sent.Header.Type) - assert.Equal(bgp.BGP_ERROR_HOLD_TIMER_EXPIRED, sent.Body.(*bgp.BGPNotification).ErrorCode) + assert.Equal(uint8(bgp.BGP_MSG_NOTIFICATION), sent.Header.Type) + assert.Equal(uint8(bgp.BGP_ERROR_HOLD_TIMER_EXPIRED), sent.Body.(*bgp.BGPNotification).ErrorCode) } func makePeerAndHandler() (*Peer, *FSMHandler) { |