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

Function TestNewFromFloat32Random

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

Source from the content-addressed store, hash-verified

168}
169
170func TestNewFromFloat32Random(t *testing.T) {
171 n := 0
172 rng := rand.New(rand.NewSource(0xdead1337))
173 for {
174 n++
175 if n == 10 {
176 break
177 }
178 in := float32((rng.Float64() - 0.5) * math.MaxFloat32 * 2)
179 want, err := NewFromString(strconv.FormatFloat(float64(in), 'f', -1, 32))
180 if err != nil {
181 t.Error(err)
182 continue
183 }
184 got := NewFromFloat32(in)
185 if !want.Equal(got) {
186 t.Errorf("in: %v, expected %s (%s, %d), got %s (%s, %d) ",
187 in, want.String(), want.value.String(), want.exp,
188 got.String(), got.value.String(), got.exp)
189 }
190 }
191}
192
193func TestNewFromFloat32Quick(t *testing.T) {
194 err := quick.Check(func(f float32) bool {

Callers

nothing calls this directly

Calls 5

NewFromStringFunction · 0.85
NewFromFloat32Function · 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…