summaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-04-03 14:14:09 -0400
committerRuss Cox <rsc@golang.org>2017-04-05 14:03:03 +0000
commita7b51cfb47b551f3352d5158b6c3a9e68a931d5b (patch)
tree8743d056c3360a84eb1b32bf7a64514de1969d55 /src/testing
parent476f55fd8aec65cb1bd3417dd1c8c583c9e385d8 (diff)
downloadgo-git-a7b51cfb47b551f3352d5158b6c3a9e68a931d5b.tar.gz
testing/quick: use Uint64 instead of Int63
Followup to CL 39152. Change-Id: I9bfed0c6071ea3d3a43294a6c4a50edc131368cf Reviewed-on: https://go-review.googlesource.com/39313 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/quick/quick.go6
-rw-r--r--src/testing/quick/quick_test.go18
2 files changed, 19 insertions, 5 deletions
diff --git a/src/testing/quick/quick.go b/src/testing/quick/quick.go
index 6415e50d65..94d873988a 100644
--- a/src/testing/quick/quick.go
+++ b/src/testing/quick/quick.go
@@ -46,11 +46,7 @@ func randFloat64(rand *rand.Rand) float64 {
// randInt64 returns a random int64.
func randInt64(rand *rand.Rand) int64 {
- x := rand.Int63() - 1<<62
- // x in [-2⁶²,2⁶²), so top two bits are 00 or 11, never 10 or 01.
- // Mix in some bits from the middle.
- x ^= x<<29 ^ x<<43
- return x
+ return int64(rand.Uint64())
}
// complexSize is the maximum length of arbitrary values that contain other
diff --git a/src/testing/quick/quick_test.go b/src/testing/quick/quick_test.go
index fe443592f8..4246cd1d3b 100644
--- a/src/testing/quick/quick_test.go
+++ b/src/testing/quick/quick_test.go
@@ -307,3 +307,21 @@ func TestNonZeroSliceAndMap(t *testing.T) {
t.Fatal(err)
}
}
+
+func TestInt64(t *testing.T) {
+ var lo, hi int64
+ f := func(x int64) bool {
+ if x < lo {
+ lo = x
+ }
+ if x > hi {
+ hi = x
+ }
+ return true
+ }
+ cfg := &Config{MaxCount: 100000}
+ Check(f, cfg)
+ if uint64(lo)>>62 == 0 || uint64(hi)>>62 == 0 {
+ t.Errorf("int64 returned range %#016x,%#016x; does not look like full range", lo, hi)
+ }
+}