Skip to content

Commit

Permalink
update test per review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanchristo committed Jun 27, 2022
1 parent 9b8a731 commit b83eb23
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions types/math/dec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func TestDec(t *testing.T) {
t.Run("TestIsZero", rapid.MakeCheck(testIsZero))
t.Run("TestIsNegative", rapid.MakeCheck(testIsNegative))
t.Run("TestIsPositive", rapid.MakeCheck(testIsPositive))
t.Run("TestIsFinite", rapid.MakeCheck(testIsFinite))
t.Run("TestNumDecimalPlaces", rapid.MakeCheck(testNumDecimalPlaces))

// Unit tests
Expand Down Expand Up @@ -553,18 +552,6 @@ func testIsPositive(t *rapid.T) {
require.Equal(t, f > 0, dec.IsPositive())
}

// Property: isFinite(f) == isFinite(NewDecFromString(f.String()))
func testIsFinite(t *rapid.T) {
// genDec always draws from float64
a := genDec.Draw(t, "a").(Dec)
require.True(t, a.IsFinite())

b, err := NewDecFromString("NaN")
require.NoError(t, err)

require.False(t, b.IsFinite())
}

// Property: floatDecimalPlaces(f) == NumDecimalPlaces(NewDecFromString(f.String()))
func testNumDecimalPlaces(t *rapid.T) {
floatAndDec := genFloatAndDec.Draw(t, "floatAndDec").(floatAndDec)
Expand Down Expand Up @@ -611,6 +598,18 @@ func floatDecimalPlaces(t *rapid.T, f float64) uint32 {
}
}

func TestIsFinite(t *testing.T) {
a, err := NewDecFromString("1.5")
require.NoError(t, err)

require.True(t, a.IsFinite())

b, err := NewDecFromString("NaN")
require.NoError(t, err)

require.False(t, b.IsFinite())
}

func TestReduce(t *testing.T) {
a, err := NewDecFromString("1.30000")
require.NoError(t, err)
Expand Down

0 comments on commit b83eb23

Please sign in to comment.