This repository was archived by the owner on Aug 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathints_test.go
156 lines (122 loc) · 3.59 KB
/
ints_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package iter
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestInts(t *testing.T) {
assert.Equal(t, []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
Ints[int]().Take(10).Collect())
}
func FuzzIntsFrom(f *testing.F) {
f.Add(0)
f.Add(27)
f.Add(168)
f.Add(41981)
f.Fuzz(func(t *testing.T, n int) {
expected := []int{}
for i := n; i < n+10; i++ {
expected = append(expected, i)
}
assert.Equal(t, expected, IntsFrom(n).Take(10).Collect())
})
}
func FuzzIntsBy(f *testing.F) {
f.Add(0)
f.Add(27)
f.Add(168)
f.Add(41981)
f.Fuzz(func(t *testing.T, n int) {
expected := []int{}
i := 0
for j := 0; j < 10; i, j = i+n, j+1 {
expected = append(expected, i)
}
assert.Equal(t, expected, IntsBy(n).Take(10).Collect())
})
}
func FuzzIntsFromBy(f *testing.F) {
f.Add(0, 0)
f.Add(27, 18)
f.Add(168, 354)
f.Add(41981, 94876)
f.Fuzz(func(t *testing.T, m, n int) {
expected := []int{}
i := m
for j := 0; j < 10; i, j = i+n, j+1 {
expected = append(expected, i)
}
assert.Equal(t, expected, IntsFromBy(m, n).Take(10).Collect())
})
}
func BenchmarkInts(b *testing.B) {
Ints[int]().Take(uint(b.N)).Consume()
}
func BenchmarkIntsFrom_negative(b *testing.B) {
IntsFrom(0).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFrom_zero(b *testing.B) {
IntsFrom(0).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFrom_positive(b *testing.B) {
IntsFrom(10000000).Take(uint(b.N)).Consume()
}
func BenchmarkIntsBy_zero(b *testing.B) {
IntsBy(0).Take(uint(b.N)).Consume()
}
func BenchmarkIntsBy_smallIncreasing(b *testing.B) {
IntsBy(1).Take(uint(b.N)).Consume()
}
func BenchmarkIntsBy_bigIncreasing(b *testing.B) {
IntsBy(10000000).Take(uint(b.N)).Consume()
}
func BenchmarkIntsBy_smallDecreasing(b *testing.B) {
IntsBy(-1).Take(uint(b.N)).Consume()
}
func BenchmarkIntsBy_bigDecreasing(b *testing.B) {
IntsBy(-10000000).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_negativeByZero(b *testing.B) {
IntsFromBy(-10000000, 0).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_negativeBySmallIncreasing(b *testing.B) {
IntsFromBy(-10000000, 1).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_negativeByLargeIncreasing(b *testing.B) {
IntsFromBy(-10000000, 10000000).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_negativeBySmallDecreasing(b *testing.B) {
IntsFromBy(-10000000, -1).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_negativeByLargeDecreasing(b *testing.B) {
IntsFromBy(-10000000, -10000000).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_zeroByZero(b *testing.B) {
IntsFromBy(0, 0).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_zeroBySmallIncreasing(b *testing.B) {
IntsFromBy(0, 1).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_zeroByLargeIncreasing(b *testing.B) {
IntsFromBy(0, 10000000).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_zeroBySmallDecreasing(b *testing.B) {
IntsFromBy(0, -1).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_zeroByLargeDecreasing(b *testing.B) {
IntsFromBy(0, -10000000).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_positiveByZero(b *testing.B) {
IntsFromBy(10000000, 0).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_positiveBySmallIncreasing(b *testing.B) {
IntsFromBy(10000000, 1).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_positiveByLargeIncreasing(b *testing.B) {
IntsFromBy(10000000, 10000000).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_positiveBySmallDecreasing(b *testing.B) {
IntsFromBy(10000000, -1).Take(uint(b.N)).Consume()
}
func BenchmarkIntsFromBy_positiveByLargeDecreasing(b *testing.B) {
IntsFromBy(10000000, -10000000).Take(uint(b.N)).Consume()
}