@@ -125,24 +125,80 @@ func TestInt8(t *testing.T) {
125
125
Expect (t , fmt .Sprintf ("%T" , value ), "int8" )
126
126
}
127
127
128
+ func TestInt8ReturnsNonZeroValues (t * testing.T ) {
129
+ f := New ()
130
+ nonZero := false
131
+ for i := 0 ; i < 100 ; i ++ {
132
+ value := f .Int8 ()
133
+ if value > 0 {
134
+ nonZero = true
135
+ break
136
+ }
137
+ }
138
+
139
+ Expect (t , nonZero , true )
140
+ }
141
+
128
142
func TestInt16 (t * testing.T ) {
129
143
f := New ()
130
144
value := f .Int16 ()
131
145
Expect (t , fmt .Sprintf ("%T" , value ), "int16" )
132
146
}
133
147
148
+ func TestInt16ReturnsNonZeroValues (t * testing.T ) {
149
+ f := New ()
150
+ nonZero := false
151
+ for i := 0 ; i < 100 ; i ++ {
152
+ value := f .Int16 ()
153
+ if value > 0 {
154
+ nonZero = true
155
+ break
156
+ }
157
+ }
158
+
159
+ Expect (t , nonZero , true )
160
+ }
161
+
134
162
func TestInt32 (t * testing.T ) {
135
163
f := New ()
136
164
value := f .Int32 ()
137
165
Expect (t , fmt .Sprintf ("%T" , value ), "int32" )
138
166
}
139
167
168
+ func TestInt32ReturnsNonZeroValues (t * testing.T ) {
169
+ f := New ()
170
+ nonZero := false
171
+ for i := 0 ; i < 100 ; i ++ {
172
+ value := f .Int32 ()
173
+ if value > 0 {
174
+ nonZero = true
175
+ break
176
+ }
177
+ }
178
+
179
+ Expect (t , nonZero , true )
180
+ }
181
+
140
182
func TestInt64 (t * testing.T ) {
141
183
f := New ()
142
184
value := f .Int64 ()
143
185
Expect (t , fmt .Sprintf ("%T" , value ), "int64" )
144
186
}
145
187
188
+ func TestInt64ReturnsNonZeroValues (t * testing.T ) {
189
+ f := New ()
190
+ nonZero := false
191
+ for i := 0 ; i < 100 ; i ++ {
192
+ value := f .Int64 ()
193
+ if value > 0 {
194
+ nonZero = true
195
+ break
196
+ }
197
+ }
198
+
199
+ Expect (t , nonZero , true )
200
+ }
201
+
146
202
func TestIntBetween (t * testing.T ) {
147
203
f := New ()
148
204
value := f .IntBetween (1 , 100 )
@@ -151,6 +207,13 @@ func TestIntBetween(t *testing.T) {
151
207
Expect (t , true , value <= 100 )
152
208
}
153
209
210
+ func TestIntBetweenWithSameValues (t * testing.T ) {
211
+ f := New ()
212
+ value := f .IntBetween (1 , 1 )
213
+ Expect (t , fmt .Sprintf ("%T" , value ), "int" )
214
+ Expect (t , 1 , value )
215
+ }
216
+
154
217
func TestIntBetweenNegativeValues (t * testing.T ) {
155
218
f := New ()
156
219
value := f .IntBetween (- 100 , - 50 )
@@ -159,12 +222,53 @@ func TestIntBetweenNegativeValues(t *testing.T) {
159
222
Expect (t , true , value <= - 50 )
160
223
}
161
224
162
- func TestIntBetweenWithMaxValues (t * testing.T ) {
225
+ func TestIntBetweenWithNegativeMinGeneratesNegativeValues (t * testing.T ) {
163
226
f := New ()
164
- value := f .IntBetween (math .MinInt , math .MaxInt )
165
- Expect (t , fmt .Sprintf ("%T" , value ), "int" )
166
- Expect (t , true , value >= math .MinInt )
167
- Expect (t , true , value <= math .MaxInt )
227
+ foundNegative := false
228
+ for i := 0 ; i < 100 ; i ++ {
229
+ value := f .IntBetween (- 100 , 100 )
230
+ if value < 0 {
231
+ foundNegative = true
232
+ break
233
+ }
234
+ }
235
+
236
+ Expect (t , true , foundNegative )
237
+ }
238
+
239
+ func TestIntBetweenWithMinMaxIntReturnDifferentValues (t * testing.T ) {
240
+ f := New ()
241
+ value1 := f .IntBetween (math .MinInt , math .MaxInt )
242
+ value2 := f .IntBetween (math .MinInt , math .MaxInt )
243
+ Expect (t , value1 != value2 , true , value1 , value2 )
244
+ }
245
+
246
+ func TestIntBetweenWithMinMaxInt8ReturnDifferentValues (t * testing.T ) {
247
+ f := New ()
248
+ value1 := f .IntBetween (math .MinInt8 , math .MaxInt8 )
249
+ value2 := f .IntBetween (math .MinInt8 , math .MaxInt8 )
250
+ Expect (t , value1 != value2 , true , value1 , value2 )
251
+ }
252
+
253
+ func TestIntBetweenWithMinMaxInt16ReturnDifferentValues (t * testing.T ) {
254
+ f := New ()
255
+ value1 := f .IntBetween (math .MinInt16 , math .MaxInt16 )
256
+ value2 := f .IntBetween (math .MinInt16 , math .MaxInt16 )
257
+ Expect (t , value1 != value2 , true , value1 , value2 )
258
+ }
259
+
260
+ func TestIntBetweenWithMinMaxInt32ReturnDifferentValues (t * testing.T ) {
261
+ f := New ()
262
+ value1 := f .IntBetween (math .MinInt32 , math .MaxInt32 )
263
+ value2 := f .IntBetween (math .MinInt32 , math .MaxInt32 )
264
+ Expect (t , value1 != value2 , true , value1 , value2 )
265
+ }
266
+
267
+ func TestIntBetweenWithMinMaxInt64ReturnDifferentValues (t * testing.T ) {
268
+ f := New ()
269
+ value1 := f .IntBetween (math .MinInt64 , math .MaxInt64 )
270
+ value2 := f .IntBetween (math .MinInt64 , math .MaxInt64 )
271
+ Expect (t , value1 != value2 , true , value1 , value2 )
168
272
}
169
273
170
274
func TestIntBetweenWithInvalidInterval (t * testing.T ) {
@@ -205,30 +309,100 @@ func TestUint(t *testing.T) {
205
309
Expect (t , fmt .Sprintf ("%T" , value ), "uint" )
206
310
}
207
311
312
+ func TestUIntReturnsNonZeroValues (t * testing.T ) {
313
+ f := New ()
314
+ nonZero := false
315
+ for i := 0 ; i < 100 ; i ++ {
316
+ value := f .UInt ()
317
+ if value > 0 {
318
+ nonZero = true
319
+ break
320
+ }
321
+ }
322
+
323
+ Expect (t , nonZero , true )
324
+ }
325
+
208
326
func TestUint8 (t * testing.T ) {
209
327
f := New ()
210
328
value := f .UInt8 ()
211
329
Expect (t , fmt .Sprintf ("%T" , value ), "uint8" )
212
330
}
213
331
332
+ func TestUInt8ReturnsNonZeroValues (t * testing.T ) {
333
+ f := New ()
334
+ nonZero := false
335
+ for i := 0 ; i < 100 ; i ++ {
336
+ value := f .UInt8 ()
337
+ if value > 0 {
338
+ nonZero = true
339
+ break
340
+ }
341
+ }
342
+
343
+ Expect (t , nonZero , true )
344
+ }
345
+
214
346
func TestUint16 (t * testing.T ) {
215
347
f := New ()
216
348
value := f .UInt16 ()
217
349
Expect (t , fmt .Sprintf ("%T" , value ), "uint16" )
218
350
}
219
351
352
+ func TestUInt16ReturnsNonZeroValues (t * testing.T ) {
353
+ f := New ()
354
+ nonZero := false
355
+ for i := 0 ; i < 100 ; i ++ {
356
+ value := f .UInt16 ()
357
+ if value > 0 {
358
+ nonZero = true
359
+ break
360
+ }
361
+ }
362
+
363
+ Expect (t , nonZero , true )
364
+ }
365
+
220
366
func TestUint32 (t * testing.T ) {
221
367
f := New ()
222
368
value := f .UInt32 ()
223
369
Expect (t , fmt .Sprintf ("%T" , value ), "uint32" )
224
370
}
225
371
372
+ func TestUInt32ReturnsNonZeroValues (t * testing.T ) {
373
+ f := New ()
374
+ nonZero := false
375
+ for i := 0 ; i < 100 ; i ++ {
376
+ value := f .UInt32 ()
377
+ if value > 0 {
378
+ nonZero = true
379
+ break
380
+ }
381
+ }
382
+
383
+ Expect (t , nonZero , true )
384
+ }
385
+
226
386
func TestUint64 (t * testing.T ) {
227
387
f := New ()
228
388
value := f .UInt64 ()
229
389
Expect (t , fmt .Sprintf ("%T" , value ), "uint64" )
230
390
}
231
391
392
+ func TestUInt64ReturnsNonZeroValues (t * testing.T ) {
393
+ f := New ()
394
+ nonZero := false
395
+ for i := 0 ; i < 100 ; i ++ {
396
+ value := f .UInt64 ()
397
+ if value > 0 {
398
+ nonZero = true
399
+ break
400
+ }
401
+ }
402
+
403
+ Expect (t , nonZero , true )
404
+ }
405
+
232
406
func TestUIntBetween (t * testing.T ) {
233
407
f := New ()
234
408
value := f .UIntBetween (1 , 100 )
0 commit comments