-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbehavior_example_test.go
More file actions
58 lines (52 loc) · 977 Bytes
/
behavior_example_test.go
File metadata and controls
58 lines (52 loc) · 977 Bytes
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package randtest_test
import (
"fmt"
"math/rand"
"github.com/acomagu/randtest"
)
func ExampleMaxBehavior() {
source := randtest.NewSource(&randtest.MaxBehavior{})
r := rand.New(source)
fmt.Println(r.Intn(10))
fmt.Println(r.Int31n(10))
fmt.Println(r.Int63n(10))
fmt.Println(r.Int31())
fmt.Println(r.Int63())
fmt.Println(r.Uint32())
fmt.Println(r.Uint64())
fmt.Println(r.Float32())
fmt.Println(r.Float64())
// Output:
// 9
// 9
// 9
// 2147483646
// 9223372036854775806
// 4294967295
// 18446744073709551615
// 0.99999994
// 0.9999999999999999
}
func ExampleMinBehavior() {
source := randtest.NewSource(&randtest.MinBehavior{})
r := rand.New(source)
fmt.Println(r.Intn(10))
fmt.Println(r.Int31n(10))
fmt.Println(r.Int63n(10))
fmt.Println(r.Int31())
fmt.Println(r.Int63())
fmt.Println(r.Uint32())
fmt.Println(r.Uint64())
fmt.Println(r.Float32())
fmt.Println(r.Float64())
// Output:
// 0
// 0
// 0
// 0
// 0
// 0
// 0
// 0
// 0
}