Skip to content

Commit

Permalink
Make staticcheck happy
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingmutant committed Nov 17, 2022
1 parent dbb2839 commit fc2893c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestUint32n(t *testing.T) {
rapid.Check(t, func(t *rapid.T) {
n := rapid.Uint32Range(1, math.MaxUint32).Draw(t, "n").(uint32)
v := rand.Uint32n(n)
if v < 0 || v >= n {
if v >= n {
t.Fatalf("got %v outside of [0, %v)", v, n)
}
})
Expand All @@ -121,7 +121,7 @@ func TestUint64n(t *testing.T) {
rapid.Check(t, func(t *rapid.T) {
n := rapid.Uint64Range(1, math.MaxUint64).Draw(t, "n").(uint64)
v := rand.Uint64n(n)
if v < 0 || v >= n {
if v >= n {
t.Fatalf("got %v outside of [0, %v)", v, n)
}
})
Expand Down
4 changes: 2 additions & 2 deletions rand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestRand_Uint32n(t *testing.T) {
r := rand.New(s)
n := rapid.Uint32Range(1, math.MaxUint32).Draw(t, "n").(uint32)
v := r.Uint32n(n)
if v < 0 || v >= n {
if v >= n {
t.Fatalf("got %v outside of [0, %v)", v, n)
}
})
Expand All @@ -111,7 +111,7 @@ func TestRand_Uint64n(t *testing.T) {
r := rand.New(s)
n := rapid.Uint64Range(1, math.MaxUint64).Draw(t, "n").(uint64)
v := r.Uint64n(n)
if v < 0 || v >= n {
if v >= n {
t.Fatalf("got %v outside of [0, %v)", v, n)
}
})
Expand Down
10 changes: 5 additions & 5 deletions std_rand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ var testSeeds = []int64{1, 1754801282, 1698661970, 1550503961}

// checkSimilarDistribution returns success if the mean and stddev of the
// two statsResults are similar.
func (this *statsResults) checkSimilarDistribution(expected *statsResults) error {
if !nearEqual(this.mean, expected.mean, expected.closeEnough, expected.maxError) {
s := fmt.Sprintf("mean %v != %v (allowed error %v, %v)", this.mean, expected.mean, expected.closeEnough, expected.maxError)
func (sr *statsResults) checkSimilarDistribution(expected *statsResults) error {
if !nearEqual(sr.mean, expected.mean, expected.closeEnough, expected.maxError) {
s := fmt.Sprintf("mean %v != %v (allowed error %v, %v)", sr.mean, expected.mean, expected.closeEnough, expected.maxError)
fmt.Println(s)
return errors.New(s)
}
if !nearEqual(this.stddev, expected.stddev, expected.closeEnough, expected.maxError) {
s := fmt.Sprintf("stddev %v != %v (allowed error %v, %v)", this.stddev, expected.stddev, expected.closeEnough, expected.maxError)
if !nearEqual(sr.stddev, expected.stddev, expected.closeEnough, expected.maxError) {
s := fmt.Sprintf("stddev %v != %v (allowed error %v, %v)", sr.stddev, expected.stddev, expected.closeEnough, expected.maxError)
fmt.Println(s)
return errors.New(s)
}
Expand Down

0 comments on commit fc2893c

Please sign in to comment.