mirror of
https://github.com/gonum/gonum.git
synced 2025-10-19 05:24:52 +08:00
stat/card: make tests parallel
This commit is contained in:
@@ -73,9 +73,15 @@ func mustCounter(c counter, err error) counter {
|
||||
}
|
||||
|
||||
func TestCounters(t *testing.T) {
|
||||
var dst []byte
|
||||
t.Parallel()
|
||||
|
||||
for _, test := range counterTests {
|
||||
test := test
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
rnd := rand.New(rand.NewSource(1))
|
||||
var dst []byte
|
||||
c := test.counter()
|
||||
for i := 0; i < int(test.count); i++ {
|
||||
dst = strconv.AppendUint(dst[:0], rnd.Uint64(), 16)
|
||||
@@ -96,16 +102,22 @@ func TestCounters(t *testing.T) {
|
||||
if got := c.Count(); !floats.EqualWithinRel(got, test.count, test.tol) {
|
||||
t.Errorf("unexpected count for %s: got:%.0f want:%.0f", test.name, got, test.count)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnion(t *testing.T) {
|
||||
var dst []byte
|
||||
t.Parallel()
|
||||
|
||||
for _, test := range counterTests {
|
||||
if strings.HasPrefix(test.name, "exact") {
|
||||
continue
|
||||
}
|
||||
test := test
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
rnd := rand.New(rand.NewSource(1))
|
||||
var dst []byte
|
||||
var cs [2]counter
|
||||
for j := range cs {
|
||||
cs[j] = test.counter()
|
||||
@@ -140,6 +152,7 @@ func TestUnion(t *testing.T) {
|
||||
if got := u.Count(); !floats.EqualWithinRel(got, 2*test.count, 2*test.tol) {
|
||||
t.Errorf("unexpected count for %s: got:%.0f want:%.0f", test.name, got, 2*test.count)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +180,8 @@ func mustResetCounter(c resetCounter, err error) resetCounter {
|
||||
}
|
||||
|
||||
func TestResetCounters(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var dst []byte
|
||||
for _, test := range counterResetTests {
|
||||
c := test.resetCounter()
|
||||
@@ -255,6 +270,8 @@ func mustCounterEncoder(c counterEncoder, err error) counterEncoder {
|
||||
}
|
||||
|
||||
func TestBinaryEncoding(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
RegisterHash(fnv.New32a)
|
||||
RegisterHash(fnv.New64a)
|
||||
defer func() {
|
||||
@@ -324,6 +341,8 @@ var invalidRegisterTests = []struct {
|
||||
}
|
||||
|
||||
func TestRegisterInvalid(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, test := range invalidRegisterTests {
|
||||
var r interface{}
|
||||
func() {
|
||||
@@ -356,6 +375,8 @@ var rhoQTests = []struct {
|
||||
}
|
||||
|
||||
func TestRhoQ(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, test := range rhoQTests {
|
||||
got := rho32q(uint32(test.bits), test.q)
|
||||
if got != test.want {
|
||||
|
Reference in New Issue
Block a user