Skip to content

Commit

Permalink
fix: ensure we convert the uint type
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed Jun 28, 2022
1 parent 914a747 commit 88c8312
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/common/variadic/uint32OrHash.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func NewUint32OrHash(value interface{}) (*Uint32OrHash, error) {
return &Uint32OrHash{
value: uint32(v),
}, nil
case uint:
return &Uint32OrHash{
value: uint32(v),
}, nil
case uint32:
return &Uint32OrHash{
value: v,
Expand Down Expand Up @@ -98,6 +102,7 @@ func (x *Uint32OrHash) IsUint32() bool {
if x == nil {
return false
}

_, is := x.value.(uint32)
return is
}
Expand Down
4 changes: 4 additions & 0 deletions lib/common/variadic/uint32OrHash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func TestNewUint32OrHash(t *testing.T) {
require.NoError(t, err)
require.Equal(t, uint32(num), res.Value())

res, err = NewUint32OrHash(uint(num))
require.NoError(t, err)
require.Equal(t, uint32(num), res.Value())

res, err = NewUint32OrHash(uint32(num))
require.NoError(t, err)
require.Equal(t, uint32(num), res.Value())
Expand Down

0 comments on commit 88c8312

Please sign in to comment.