forked from gookit/goutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_test.go
51 lines (38 loc) · 1.14 KB
/
check_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 goutil_test
import (
"testing"
"github.com/gookit/goutil"
"github.com/gookit/goutil/testutil/assert"
)
func TestIsEmpty(t *testing.T) {
is := assert.New(t)
is.True(goutil.IsEmpty(nil))
is.False(goutil.IsZero("abc"))
is.False(goutil.IsEmpty("abc"))
}
func TestIsFunc(t *testing.T) {
is := assert.New(t)
is.False(goutil.IsFunc(nil))
is.True(goutil.IsFunc(goutil.IsEqual))
}
func TestIsEqual(t *testing.T) {
is := assert.New(t)
is.True(goutil.IsNil(nil))
is.False(goutil.IsNil("abc"))
is.True(goutil.IsEqual("a", "a"))
is.True(goutil.IsEqual([]string{"a"}, []string{"a"}))
is.True(goutil.IsEqual(23, 23))
is.True(goutil.IsEqual(nil, nil))
is.True(goutil.IsEqual([]byte("abc"), []byte("abc")))
is.False(goutil.IsEqual([]byte("abc"), "abc"))
is.False(goutil.IsEqual(nil, 23))
is.False(goutil.IsEqual(goutil.IsEmpty, 23))
}
func TestIsContains(t *testing.T) {
is := assert.New(t)
is.True(goutil.Contains("abc", "a"))
is.True(goutil.Contains([]string{"abc", "def"}, "abc"))
is.True(goutil.Contains(map[int]string{2: "abc", 4: "def"}, 4))
is.False(goutil.Contains("abc", "def"))
is.False(goutil.IsContains("abc", "def"))
}