@@ -40,6 +40,33 @@ func Test_RNG(t *testing.T) {
4040 check (t , RNG (123454321 ), RNG (123454321 ))
4141 check (t , RNGUint32 (), RNGUint32 ())
4242 }
43+
44+ // for coverage
45+ if GetOptimizedRand ().Intn (55555 ) == GetOptimizedRand ().Intn (55555 ) {
46+ t .Errorf ("GetOptimizedRand(55555) returned the same value twice!" )
47+ }
48+ if GetSharedRand ().Intn (55555 ) == GetSharedRand ().Intn (55555 ) {
49+ t .Errorf ("GetSharedRand(55555) returned the same value twice!" )
50+ }
51+ r := AcquireRand ()
52+ one := r .Intn (55555 )
53+ two := r .Intn (55555 )
54+ if one == two {
55+ t .Errorf ("AcquireRand() returned the same value twice!" )
56+ }
57+ ReleaseRand (r )
58+ r = AcquireRand ()
59+ one1 := r .Intn (55555 )
60+ two1 := r .Intn (55555 )
61+ if one1 == two1 {
62+ t .Errorf ("AcquireRand() returned the same value twice!" )
63+ }
64+ if one == one1 {
65+ t .Errorf ("AcquireRand()[2] returned the same value twice!" )
66+ }
67+ if two == two1 {
68+ t .Errorf ("AcquireRand()[2] returned the same value twice!" )
69+ }
4370}
4471
4572func Test_OneInA (t * testing.T ) {
@@ -139,9 +166,9 @@ func Test_RNGUint32(t *testing.T) {
139166
140167func Benchmark_RandStr (b * testing.B ) {
141168 toTest := []int {5 , 25 , 55 , 500 , 55555 }
142- for _ , n := range toTest {
169+ for n := range toTest {
143170 for i := 1 ; i != 5 ; i ++ {
144- b .Run (fmt .Sprintf ("%dchar /run%d" , n , i ), func (b * testing.B ) {
171+ b .Run (fmt .Sprintf ("lenSeries%d /run%d" , n , i ), func (b * testing.B ) {
145172 b .ReportAllocs ()
146173 b .ResetTimer ()
147174 for tn := 0 ; tn != b .N ; tn ++ {
0 commit comments