Files
gonum/internal/testrand/extreme_test.go
Dan Kortschak cf3307fa63 all: partially migrate to math/rand/v2
This is not intended to be a completed transition since it leaves the
libraries unusable to external client code, but rather as a step towards
use of math/rand/v2. This initial step allows repair of sequence change
failures without having to worry about API difference.
2025-02-01 22:18:04 +10:30

35 lines
678 B
Go

// Copyright ©2020 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package testrand
import (
"math"
"testing"
"gonum.org/v1/gonum/internal/rand"
)
func TestExtreme_NaN(t *testing.T) {
src := rand.NewSource(1)
rnd := rand.New(src)
ext := newExtreme(0, 1, rnd)
check64 := func(v float64) {
if !math.IsNaN(v) {
t.Errorf("expected NaN, got %v", v)
}
}
check32 := func(v float32) {
if !math.IsNaN(float64(v)) {
t.Errorf("expected NaN, got %v", v)
}
}
check64(ext.ExpFloat64())
check64(ext.Float64())
check64(ext.NormFloat64())
check32(ext.Float32())
}