示例#1
0
func TestSqrt(t *testing.T) {
	f := func(x float32) bool {
		y := Sqrt(x)
		if IsNaN(y) && IsNaN(sqrt(x)) {
			return true
		}
		return floats.EqualWithinRel(float64(y), float64(sqrt(x)), tol)
	}
	if err := quick.Check(f, nil); err != nil {
		t.Error(err)
	}
}
示例#2
0
func TestHypot(t *testing.T) {
	f := func(x struct{ X, Y float32 }) bool {
		y := Hypot(x.X, x.Y)
		if math.Hypot(float64(x.X), float64(x.Y)) > math.MaxFloat32 {
			return true
		}
		return floats.EqualWithinRel(float64(y), math.Hypot(float64(x.X), float64(x.Y)), tol)
	}
	if err := quick.Check(f, nil); err != nil {
		t.Error(err)
	}
}