The predictableRandom test can only run once successfully (fixes #1184)

This commit is contained in:
Jakob Borg 2015-01-06 23:03:35 +01:00
parent 9d6ef24660
commit a7a317c284
1 changed files with 13 additions and 6 deletions

View File

@ -15,14 +15,21 @@
package main
import "testing"
import (
"sync"
"testing"
)
var predictableRandomTest sync.Once
func TestPredictableRandom(t *testing.T) {
// predictable random sequence is predictable
e := 3440579354231278675
if v := predictableRandom.Int(); v != e {
t.Errorf("Unexpected random value %d != %d", v, e)
}
predictableRandomTest.Do(func() {
// predictable random sequence is predictable
e := 3440579354231278675
if v := predictableRandom.Int(); v != e {
t.Errorf("Unexpected random value %d != %d", v, e)
}
})
}
func TestSeedFromBytes(t *testing.T) {