MCPcopy
hub / github.com/shopspring/decimal / TestNewFromFloatRandom

Function TestNewFromFloatRandom

decimal_test.go:133–154  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

131}
132
133func TestNewFromFloatRandom(t *testing.T) {
134 n := 0
135 rng := rand.New(rand.NewSource(0xdead1337))
136 for {
137 n++
138 if n == 10 {
139 break
140 }
141 in := (rng.Float64() - 0.5) * math.MaxFloat64 * 2
142 want, err := NewFromString(strconv.FormatFloat(in, 'f', -1, 64))
143 if err != nil {
144 t.Error(err)
145 continue
146 }
147 got := NewFromFloat(in)
148 if !want.Equal(got) {
149 t.Errorf("in: %v, expected %s (%s, %d), got %s (%s, %d) ",
150 in, want.String(), want.value.String(), want.exp,
151 got.String(), got.value.String(), got.exp)
152 }
153 }
154}
155
156func TestNewFromFloatQuick(t *testing.T) {
157 err := quick.Check(func(f float64) bool {

Callers

nothing calls this directly

Calls 5

NewFromStringFunction · 0.85
NewFromFloatFunction · 0.85
Float64Method · 0.80
EqualMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…