-
Notifications
You must be signed in to change notification settings - Fork 25
/
generator_test.go
43 lines (33 loc) · 1023 Bytes
/
generator_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2019 Gregory Petrosyan <gregory.petrosyan@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
package rapid
import "testing"
type trivialGenImpl struct{}
func (trivialGenImpl) String() string { return "" }
func (trivialGenImpl) value(t *T) uint64 { return t.s.drawBits(64) }
func BenchmarkTrivialGenImplValue(b *testing.B) {
t := newT(nil, newRandomBitStream(baseSeed(), false), false, nil)
g := trivialGenImpl{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
g.value(t)
}
}
func BenchmarkGenerator_Value(b *testing.B) {
t := newT(nil, newRandomBitStream(baseSeed(), false), false, nil)
g := newGenerator[uint64](trivialGenImpl{})
b.ResetTimer()
for i := 0; i < b.N; i++ {
g.value(t)
}
}
func TestExampleHelper(t *testing.T) {
g := Custom(func(t *T) int {
t.Helper()
return Int().Draw(t, t.Name())
})
g.Example(0)
}