-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdrop_while_slice_test.go
More file actions
45 lines (34 loc) · 926 Bytes
/
drop_while_slice_test.go
File metadata and controls
45 lines (34 loc) · 926 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
package pipe
import (
"testing"
)
func TestDropWhileSlice(t *testing.T) {
in := []int{1, 2, 3, 2}
lessThan := func(x int) func(int) bool {
return func(item int) bool {
return item < x
}
}
result := DropWhileSlice(lessThan(3), in).([]int)
if len(result) != 2 {
t.Fatal("DropWhileSlice should have dropped all results until 3, but output", result)
}
if result[0] != 3 {
t.Fatal("DropWhile should have dropped all results until 3, but output", result)
}
if result[1] != 2 {
t.Fatal("DropWhile should have dropped all results until 3, but output", result)
}
}
func TestDropWhileSliceNeverPassing(t *testing.T) {
in := []int{1, 2, 3, 2}
lessThan := func(x int) func(int) bool {
return func(item int) bool {
return item < x
}
}
result := DropWhileSlice(lessThan(6), in).([]int)
if len(result) != 0 {
t.Fatal("DropWhileSlice should have dropped all results, but output", result)
}
}