-
Notifications
You must be signed in to change notification settings - Fork 1
/
string_list_test.go
129 lines (96 loc) · 3.1 KB
/
string_list_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
package convert_test
import (
"testing"
"github.com/iostrovok/go-convert"
)
func TestListOfStringsP(t *testing.T) {
mList := make([]string, 0)
a := convert.ListOfStringsP(mList)
EqualStringsArray(t, a, mList)
a = convert.ListOfStringsP(nil)
EqualStringsArray(t, a, mList)
a = convert.ListOfStringsP([]string{"10", "20", "40", ""})
EqualStringsArray(t, a, []string{"10", "20", "40"})
}
func TestListOfStringsPErr_checkLen(t *testing.T) {
mList := make([]string, 0)
_, e := convert.ListOfStringsPErr(mList, true)
NotNil2(t, e)
_, e = convert.ListOfStringsPErr(nil, true)
NotNil2(t, e)
mList2 := []string{"10", "20", "40", ""}
a, e := convert.ListOfStringsPErr(mList2, true)
Nil2(t, e)
EqualStringsArray(t, a, []string{"10", "20", "40"})
a, e = convert.ListOfStringsPErr(mList2, true)
Nil2(t, e)
EqualStringsArray(t, a, []string{"10", "20", "40"})
_, e = convert.ListOfStringsPErr([]string{"", "", ""}, true)
NotNil2(t, e)
}
func TestListOfStringsPErr_no_checkLen(t *testing.T) {
mList := make([]string, 0)
a, e := convert.ListOfStringsPErr(mList, false)
Nil2(t, e)
EqualStringsArray(t, a, mList)
mListFull := []string{"10", "20", "40"}
a, e = convert.ListOfStringsPErr(mListFull, false)
Nil2(t, e)
EqualStringsArray(t, a, mListFull)
mListEmpty := []string{"10", "20", "40", ""}
_, e = convert.ListOfStringsPErr(mListEmpty, false)
Nil2(t, e)
EqualStringsArray(t, a, mListFull)
}
func TestListOfStringsErr(t *testing.T) {
mList := make([]string, 0)
a, e := convert.ListOfStringsErr(mList, false)
Nil2(t, e)
EqualStringsArray(t, a, mList)
_, e = convert.ListOfStringsErr(mList, true)
NotNil2(t, e)
_, e = convert.ListOfStringsErr(nil, true)
NotNil2(t, e)
mListFull := []string{"10", "20", "40"}
a, e = convert.ListOfStringsErr(mListFull, false)
Nil2(t, e)
EqualStringsArray(t, a, mListFull)
mListEmpty := []string{"10", "20", "40", ""}
a, e = convert.ListOfStringsErr(mListEmpty, false)
Nil2(t, e)
EqualStringsArray(t, a, mListEmpty)
}
func TestListOfStringsP_Empty(t *testing.T) {
mList := make([]string, 0)
a := convert.ListOfStringsP(nil)
EqualStringsArray(t, a, mList)
a = convert.ListOfStringsP(mList)
EqualStringsArray(t, a, mList)
a = convert.ListOfStringsP(mList)
EqualStringsArray(t, a, mList)
a = convert.ListOfStringsP([]string{""})
EqualStringsArray(t, a, mList)
}
func TestListOfStringsP_Full(t *testing.T) {
mListFull := []string{"10", "20", "40"}
a := convert.ListOfStringsP(mListFull)
EqualStringsArray(t, a, mListFull)
mListEmpty := []string{"10", "20", "", "40"}
a = convert.ListOfStringsP(mListEmpty)
EqualStringsArray(t, a, []string{"10", "20", "40"})
}
func TestListOfStrings(t *testing.T) {
mList := make([]string, 0)
a := convert.ListOfStrings(nil)
EqualStringsArray(t, a, mList)
a = convert.ListOfStrings(mList)
EqualStringsArray(t, a, mList)
a = convert.ListOfStrings(mList)
EqualStringsArray(t, a, mList)
mListFull := []string{"10", "20", "40"}
a = convert.ListOfStrings(mListFull)
EqualStringsArray(t, a, mListFull)
mListEmpty := []string{"10", "20", "40", ""}
a = convert.ListOfStrings(mListEmpty)
EqualStringsArray(t, a, mListEmpty)
}