Skip to content

Commit

Permalink
Testing[entropy]: fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
yunginnanet committed Sep 7, 2023
1 parent 917be20 commit a063fa9
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions entropy/entropy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,33 @@ func Test_RNG(t *testing.T) {
check(t, RNG(123454321), RNG(123454321))
check(t, RNGUint32(), RNGUint32())
}

// for coverage
if GetOptimizedRand().Intn(55555) == GetOptimizedRand().Intn(55555) {
t.Errorf("GetOptimizedRand(55555) returned the same value twice!")
}
if GetSharedRand().Intn(55555) == GetSharedRand().Intn(55555) {
t.Errorf("GetSharedRand(55555) returned the same value twice!")
}
r := AcquireRand()
one := r.Intn(55555)
two := r.Intn(55555)
if one == two {
t.Errorf("AcquireRand() returned the same value twice!")
}
ReleaseRand(r)
r = AcquireRand()
one1 := r.Intn(55555)
two1 := r.Intn(55555)
if one1 == two1 {
t.Errorf("AcquireRand() returned the same value twice!")
}
if one == one1 {
t.Errorf("AcquireRand()[2] returned the same value twice!")
}
if two == two1 {
t.Errorf("AcquireRand()[2] returned the same value twice!")
}
}

func Test_OneInA(t *testing.T) {
Expand Down Expand Up @@ -139,9 +166,9 @@ func Test_RNGUint32(t *testing.T) {

func Benchmark_RandStr(b *testing.B) {
toTest := []int{5, 25, 55, 500, 55555}
for _, n := range toTest {
for n := range toTest {
for i := 1; i != 5; i++ {
b.Run(fmt.Sprintf("%dchar/run%d", n, i), func(b *testing.B) {
b.Run(fmt.Sprintf("lenSeries%d/run%d", n, i), func(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for tn := 0; tn != b.N; tn++ {
Expand Down

0 comments on commit a063fa9

Please sign in to comment.