-
Notifications
You must be signed in to change notification settings - Fork 2
/
range_test.go
53 lines (45 loc) · 1.21 KB
/
range_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
package iterium
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestRange(t *testing.T) {
values := Range(5)
if slice, err := values.Slice(); assert.Nil(t, err) {
assert.Exactly(t, []int{0, 1, 2, 3, 4}, slice)
}
}
func TestRangeEmpty(t *testing.T) {
values := Range[int]()
if slice, err := values.Slice(); assert.Nil(t, err) {
assert.Exactly(t, []int{}, slice)
}
wrongArgs := Range(50, 1)
if slice, err := wrongArgs.Slice(); assert.Nil(t, err) {
assert.Exactly(t, []int{}, slice)
}
}
func TestRangeDefaultStep(t *testing.T) {
values := Range(0, 5)
if slice, err := values.Slice(); assert.Nil(t, err) {
assert.Exactly(t, []int{0, 1, 2, 3, 4}, slice)
}
}
func TestRangeSigned(t *testing.T) {
values := Range(-5)
if slice, err := values.Slice(); assert.Nil(t, err) {
assert.Exactly(t, []int{0, -1, -2, -3, -4}, slice)
}
}
func TestRangeWithStep(t *testing.T) {
values := Range(0, 10, 2)
if slice, err := values.Slice(); assert.Nil(t, err) {
assert.Exactly(t, []int{0, 2, 4, 6, 8}, slice)
}
}
func TestRangeFloat(t *testing.T) {
values := Range(0.0, 10.0, 1.5)
if slice, err := values.Slice(); assert.Nil(t, err) {
assert.Exactly(t, []float64{0, 1.5, 3, 4.5, 6, 7.5, 9}, slice)
}
}