refactor: use the built-in max/min to simplify the code (#24112)
Signed-off-by: riyueguang <rustruby@outlook.com>
This commit is contained in:
+2
-16
@@ -221,20 +221,6 @@ func (s *intTestSuite) TestIdentInt() {
|
||||
}
|
||||
}
|
||||
|
||||
func minint(i1, i2 int64) int64 {
|
||||
if i1 < i2 {
|
||||
return i1
|
||||
}
|
||||
return i2
|
||||
}
|
||||
|
||||
func maxint(i1, i2 int64) int64 {
|
||||
if i1 > i2 {
|
||||
return i1
|
||||
}
|
||||
return i2
|
||||
}
|
||||
|
||||
func (s *intTestSuite) TestArithInt() {
|
||||
for d := 0; d < 1000; d++ {
|
||||
n1 := int64(rand.Int31())
|
||||
@@ -254,8 +240,8 @@ func (s *intTestSuite) TestArithInt() {
|
||||
{i1.SubRaw(n2), n1 - n2},
|
||||
{i1.MulRaw(n2), n1 * n2},
|
||||
{i1.QuoRaw(n2), n1 / n2},
|
||||
{math.MinInt(i1, i2), minint(n1, n2)},
|
||||
{math.MaxInt(i1, i2), maxint(n1, n2)},
|
||||
{math.MinInt(i1, i2), min(n1, n2)},
|
||||
{math.MaxInt(i1, i2), max(n1, n2)},
|
||||
{i1.Neg(), -n1},
|
||||
{i1.Abs(), n1},
|
||||
{i1.Neg().Abs(), n1},
|
||||
|
||||
+2
-16
@@ -136,8 +136,8 @@ func (s *uintTestSuite) TestArithUint() {
|
||||
{u1.AddUint64(n2), n1 + n2},
|
||||
{u1.MulUint64(n2), n1 * n2},
|
||||
{u1.QuoUint64(n2), n1 / n2},
|
||||
{sdkmath.MinUint(u1, u2), minuint(n1, n2)},
|
||||
{sdkmath.MaxUint(u1, u2), maxuint(n1, n2)},
|
||||
{sdkmath.MinUint(u1, u2), min(n1, n2)},
|
||||
{sdkmath.MaxUint(u1, u2), max(n1, n2)},
|
||||
{u1.Incr(), n1 + 1},
|
||||
}
|
||||
|
||||
@@ -316,20 +316,6 @@ func (s *uintTestSuite) TestRelativePow() {
|
||||
}
|
||||
}
|
||||
|
||||
func minuint(i1, i2 uint64) uint64 {
|
||||
if i1 < i2 {
|
||||
return i1
|
||||
}
|
||||
return i2
|
||||
}
|
||||
|
||||
func maxuint(i1, i2 uint64) uint64 {
|
||||
if i1 > i2 {
|
||||
return i1
|
||||
}
|
||||
return i2
|
||||
}
|
||||
|
||||
func TestRoundTripMarshalToUint(t *testing.T) {
|
||||
values := []uint64{
|
||||
0,
|
||||
|
||||
Reference in New Issue
Block a user