Skip to content

Commit

Permalink
packet/bgp: use strconv.FormatInt() instead of strconv.Itoa() in tests
Browse files Browse the repository at this point in the history
Itoa() takes an int which will only be 32-bit on i386 and similar
architectures. In tests, some constants are too big. Therefore, switch
all uses of strconv.Itoa() to strconv.FormatInt().

Without this change, we get:

```
src/github.com/osrg/gobgp/packet/bgp/bgp_test.go:1123:41: constant 2864434397 overflows int
```
  • Loading branch information
vincentbernat authored and fujita committed Dec 16, 2017
1 parent 1227ace commit a44dd5d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packet/bgp/bgp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ func Test_ParseEthernetSegmentIdentifier(t *testing.T) {
}, esi)

// ESI_LACP
args = []string{"lacp", "aa:bb:cc:dd:ee:ff", strconv.Itoa(0x1122)} // lower case
args = []string{"lacp", "aa:bb:cc:dd:ee:ff", strconv.FormatInt(0x1122, 10)} // lower case
esi, err = ParseEthernetSegmentIdentifier(args)
assert.Nil(err)
assert.Equal(EthernetSegmentIdentifier{
Expand All @@ -1149,7 +1149,7 @@ func Test_ParseEthernetSegmentIdentifier(t *testing.T) {
}, esi)

// ESI_MSTP
args = []string{"esi_mstp", "aa:bb:cc:dd:ee:ff", strconv.Itoa(0x1122)} // omit "ESI_" + lower case
args = []string{"esi_mstp", "aa:bb:cc:dd:ee:ff", strconv.FormatInt(0x1122, 10)} // omit "ESI_" + lower case
esi, err = ParseEthernetSegmentIdentifier(args)
assert.Nil(err)
assert.Equal(EthernetSegmentIdentifier{
Expand All @@ -1158,7 +1158,7 @@ func Test_ParseEthernetSegmentIdentifier(t *testing.T) {
}, esi)

// ESI_MAC
args = []string{"ESI_MAC", "aa:bb:cc:dd:ee:ff", strconv.Itoa(0x112233)}
args = []string{"ESI_MAC", "aa:bb:cc:dd:ee:ff", strconv.FormatInt(0x112233, 10)}
esi, err = ParseEthernetSegmentIdentifier(args)
assert.Nil(err)
assert.Equal(EthernetSegmentIdentifier{
Expand All @@ -1167,7 +1167,7 @@ func Test_ParseEthernetSegmentIdentifier(t *testing.T) {
}, esi)

// ESI_ROUTERID
args = []string{"ESI_ROUTERID", "1.1.1.1", strconv.Itoa(0x11223344)}
args = []string{"ESI_ROUTERID", "1.1.1.1", strconv.FormatInt(0x11223344, 10)}
esi, err = ParseEthernetSegmentIdentifier(args)
assert.Nil(err)
assert.Equal(EthernetSegmentIdentifier{
Expand All @@ -1176,7 +1176,7 @@ func Test_ParseEthernetSegmentIdentifier(t *testing.T) {
}, esi)

// ESI_AS
args = []string{"ESI_AS", strconv.Itoa(0xaabbccdd), strconv.Itoa(0x11223344)}
args = []string{"ESI_AS", strconv.FormatInt(0xaabbccdd, 10), strconv.FormatInt(0x11223344, 10)}
esi, err = ParseEthernetSegmentIdentifier(args)
assert.Nil(err)
assert.Equal(EthernetSegmentIdentifier{
Expand Down

0 comments on commit a44dd5d

Please sign in to comment.