mirror of
https://github.com/gonum/gonum.git
synced 2025-10-19 21:44:41 +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) {
|
func TestCounters(t *testing.T) {
|
||||||
var dst []byte
|
t.Parallel()
|
||||||
|
|
||||||
for _, test := range counterTests {
|
for _, test := range counterTests {
|
||||||
|
test := test
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
|
var dst []byte
|
||||||
c := test.counter()
|
c := test.counter()
|
||||||
for i := 0; i < int(test.count); i++ {
|
for i := 0; i < int(test.count); i++ {
|
||||||
dst = strconv.AppendUint(dst[:0], rnd.Uint64(), 16)
|
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) {
|
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)
|
t.Errorf("unexpected count for %s: got:%.0f want:%.0f", test.name, got, test.count)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnion(t *testing.T) {
|
func TestUnion(t *testing.T) {
|
||||||
var dst []byte
|
t.Parallel()
|
||||||
|
|
||||||
for _, test := range counterTests {
|
for _, test := range counterTests {
|
||||||
if strings.HasPrefix(test.name, "exact") {
|
if strings.HasPrefix(test.name, "exact") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
test := test
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
|
var dst []byte
|
||||||
var cs [2]counter
|
var cs [2]counter
|
||||||
for j := range cs {
|
for j := range cs {
|
||||||
cs[j] = test.counter()
|
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) {
|
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)
|
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) {
|
func TestResetCounters(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
var dst []byte
|
var dst []byte
|
||||||
for _, test := range counterResetTests {
|
for _, test := range counterResetTests {
|
||||||
c := test.resetCounter()
|
c := test.resetCounter()
|
||||||
@@ -255,6 +270,8 @@ func mustCounterEncoder(c counterEncoder, err error) counterEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBinaryEncoding(t *testing.T) {
|
func TestBinaryEncoding(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
RegisterHash(fnv.New32a)
|
RegisterHash(fnv.New32a)
|
||||||
RegisterHash(fnv.New64a)
|
RegisterHash(fnv.New64a)
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -324,6 +341,8 @@ var invalidRegisterTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterInvalid(t *testing.T) {
|
func TestRegisterInvalid(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
for _, test := range invalidRegisterTests {
|
for _, test := range invalidRegisterTests {
|
||||||
var r interface{}
|
var r interface{}
|
||||||
func() {
|
func() {
|
||||||
@@ -356,6 +375,8 @@ var rhoQTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRhoQ(t *testing.T) {
|
func TestRhoQ(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
for _, test := range rhoQTests {
|
for _, test := range rhoQTests {
|
||||||
got := rho32q(uint32(test.bits), test.q)
|
got := rho32q(uint32(test.bits), test.q)
|
||||||
if got != test.want {
|
if got != test.want {
|
||||||
|
Reference in New Issue
Block a user