forked from jianfengye/collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstr_collection_test.go
50 lines (46 loc) · 987 Bytes
/
str_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
package collection
import (
"reflect"
"testing"
)
func TestStrCollection_Insert(t *testing.T) {
{
a := NewStrCollection([]string{"1","2","3"})
b, err := a.Insert(1, "10").ToStrings()
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(b, []string{"1", "10", "2", "3"}) {
t.Error("insert error")
}
}
{
a := NewStrCollection([]string{"1","2","3"})
b, err := a.Insert(0, "10").ToStrings()
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(b, []string{"10", "1", "2", "3"}) {
t.Error("insert 0 error")
}
}
{
a := NewStrCollection([]string{"1","2","3"})
b, err := a.Insert(3, "10").ToStrings()
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(b, []string{"1", "2", "3", "10"}) {
t.Error("insert length error")
}
}
}
func TestStrCollection_FromJson(t *testing.T) {
data := `["aa", "bb"]`
objColl := NewStrCollection([]string{})
err := objColl.FromJson([]byte(data))
if err != nil {
t.Error(err)
}
objColl.DD()
}