forked from Barbery/phpGo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathempty_test.go
More file actions
47 lines (37 loc) · 695 Bytes
/
empty_test.go
File metadata and controls
47 lines (37 loc) · 695 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
46
47
package phpGo
import (
"testing"
)
type tmpStruct struct {
A string
B int
}
func TestEmpty(t *testing.T) {
if !Empty(nil) {
t.Error()
}
if !Empty("") {
t.Error()
}
if !Empty("0") {
t.Error()
}
if !Empty(false) {
t.Error()
}
tmpArr := [2]interface{}{0, 1}
if !Empty(tmpArr, 0) || Empty(tmpArr, 1) {
t.Error()
}
if !Empty([]int{}) || !Empty([]string{}) {
t.Error()
}
tmpMap := map[interface{}]interface{}{"asd": "1", 123: "2", "123": "3"}
if !Empty(tmpMap, "aa") || Empty(tmpMap, 123) || Empty(tmpMap, "asd") {
t.Error()
}
tmpStruct := tmpStruct{A: "123", B: 0}
if Empty(tmpStruct) || Empty(tmpStruct, "A") || !Empty(tmpStruct, "B") {
t.Error()
}
}