-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdrop_test.go
138 lines (92 loc) · 2.62 KB
/
drop_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
package ranges
import "testing"
func TestDrop(t *testing.T) {
t.Parallel()
sliceCopy := Slice(Drop[int](Only(1, 2, 3, 4, 5), 3))
assertEqual(t, sliceCopy, []int{4, 5})
}
func TestDropZero(t *testing.T) {
t.Parallel()
sliceCopy := Slice(Drop[int](Only(1, 2, 3), 0))
assertEqual(t, sliceCopy, []int{1, 2, 3})
}
func TestDropNegative(t *testing.T) {
t.Parallel()
sliceCopy := Slice(Drop[int](Only(1, 2, 3), -10))
assertEqual(t, sliceCopy, []int{1, 2, 3})
}
func TestDropCallFrontFirst(t *testing.T) {
t.Parallel()
dropRange := Drop[int](Only(1, 2, 3, 4, 5), 3)
assertHasFront(t, dropRange, 4)
}
func TestDropCallPopFrontFirst(t *testing.T) {
t.Parallel()
dropRange := Drop[int](Only(1, 2, 3, 4, 5), 3)
dropRange.PopFront()
assertHasFront(t, dropRange, 5)
}
func TestDropF(t *testing.T) {
t.Parallel()
dropRange := DropF(Only(1, 2, 3, 4, 5), 3)
sliceCopy := SliceF(dropRange.Save())
sliceCopy2 := SliceF(dropRange.Save())
assertEqual(t, sliceCopy, []int{4, 5})
assertEqual(t, sliceCopy2, []int{4, 5})
}
func TestDropFCallFrontFirst(t *testing.T) {
t.Parallel()
dropRange := DropF(Only(1, 2, 3, 4, 5), 3)
assertHasFront(t, dropRange, 4)
}
func TestDropFCallPopFrontFirst(t *testing.T) {
t.Parallel()
dropRange := DropF(Only(1, 2, 3, 4, 5), 3)
dropRange.PopFront()
assertHasFront(t, dropRange, 5)
}
func TestDropFZero(t *testing.T) {
t.Parallel()
sliceCopy := Slice[int](DropF(Only(1, 2, 3), 0))
assertEqual(t, sliceCopy, []int{1, 2, 3})
}
func TestDropFNegative(t *testing.T) {
t.Parallel()
sliceCopy := Slice[int](DropF(Only(1, 2, 3), -10))
assertEqual(t, sliceCopy, []int{1, 2, 3})
}
func TestDropB(t *testing.T) {
t.Parallel()
dropRange := DropB(Only(1, 2, 3, 4, 5), 3)
sliceCopy := SliceB(dropRange.SaveB())
sliceCopy2 := SliceB(dropRange.SaveB())
assertEqual(t, sliceCopy, []int{4, 5})
assertEqual(t, sliceCopy2, []int{4, 5})
assertHasBack(t, dropRange, 5)
dropRange.PopBack()
assertHasBack(t, dropRange, 4)
dropRange.PopBack()
assertEmpty(t, dropRange)
}
func TestDropR(t *testing.T) {
t.Parallel()
r := DropR(Only(1, 2, 3, 4, 5), 3)
r2 := r.SaveR()
r.PopFront()
assertEqual(t, r2.Get(0), 4)
assertEqual(t, SliceR(r), []int{5})
assertEqual(t, SliceR(r2), []int{4, 5})
}
// Ensure we prime the drop range if we .Get() before other operations.
func TestDropRGetPrimed(t *testing.T) {
t.Parallel()
r := DropR(Only(1, 2, 3, 4, 5), 3)
assertEqual(t, r.Get(0), 4)
assertEqual(t, r.Get(1), 5)
}
// Ensure we prime the drop range if we check length before other operations.
func TestDropRLen(t *testing.T) {
t.Parallel()
r := DropR(Only(1, 2, 3, 4, 5), 3)
assertEqual(t, r.Len(), 2)
}