forked from jianfengye/collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathint_collection_test.go
51 lines (47 loc) · 930 Bytes
/
int_collection_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
package collection
import (
"reflect"
"testing"
)
func TestIntCollection_Insert(t *testing.T) {
{
a := NewIntCollection([]int{1,2,3})
b, err := a.Insert(1, 10).ToInts()
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(b, []int{1, 10, 2, 3}) {
t.Error("insert error")
}
}
{
a := NewIntCollection([]int{1,2,3})
b, err := a.Insert(0, 10).ToInts()
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(b, []int{10, 1, 2, 3}) {
t.Error("insert 0 error")
}
}
{
a := NewIntCollection([]int{1,2,3})
b, err := a.Insert(3, 10).ToInts()
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(b, []int{1, 2, 3, 10}) {
t.Error("insert length error")
}
}
}
func TestIntCollection_Filter(t *testing.T) {
intColl := NewIntCollection([]int{1,2,3})
a, err := intColl.First().ToInt()
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(a, 1) {
t.Error("filter error")
}
}