feat: add uint IsNil method (#13381)
This commit is contained in:
parent
abdf61e292
commit
55373cb614
@ -31,4 +31,5 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
* [#13381](https://github.com/cosmos/cosmos-sdk/pull/13381) Add uint `IsNil` method.
|
||||
* [#12634](https://github.com/cosmos/cosmos-sdk/pull/12634) Move `sdk.Dec` to math package, call it `LegacyDec`.
|
||||
|
||||
@ -18,6 +18,11 @@ func (u Uint) BigInt() *big.Int {
|
||||
return new(big.Int).Set(u.i)
|
||||
}
|
||||
|
||||
// IsNil returns true if Uint is uninitialized
|
||||
func (u Uint) IsNil() bool {
|
||||
return u.i == nil
|
||||
}
|
||||
|
||||
// NewUintFromBigUint constructs Uint from big.Uint
|
||||
func NewUintFromBigInt(i *big.Int) Uint {
|
||||
u, err := checkNewUint(i)
|
||||
|
||||
@ -91,6 +91,11 @@ func (s *uintTestSuite) TestUintPanics() {
|
||||
s.Require().True(sdkmath.ZeroUint().LTE(sdkmath.OneUint()))
|
||||
}
|
||||
|
||||
func (s *uintTestSuite) TestIsNil() {
|
||||
s.Require().False(sdkmath.OneUint().IsNil())
|
||||
s.Require().True(sdkmath.Uint{}.IsNil())
|
||||
}
|
||||
|
||||
func (s *uintTestSuite) TestArithUint() {
|
||||
for d := 0; d < 1000; d++ {
|
||||
n1 := uint64(rand.Uint32())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user