This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate_test.go
74 lines (58 loc) · 1.51 KB
/
template_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
package nero
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
type myType struct{}
func TestFuncs(t *testing.T) {
t.Run("typeFunc", func(t *testing.T) {
got := typeFunc(1)
expect := "int"
assert.Equal(t, expect, got)
got = typeFunc(&myType{})
expect = "nero.myType"
assert.Equal(t, expect, got)
})
t.Run("rawTypeFunc", func(t *testing.T) {
got := rawTypeFunc(1)
expect := "int"
assert.Equal(t, expect, got)
got = rawTypeFunc(&myType{})
expect = "*nero.myType"
assert.Equal(t, expect, got)
})
t.Run("zeroFunc", func(t *testing.T) {
got := zeroValueFunc(0)
expect := "0"
assert.Equal(t, expect, got)
got = zeroValueFunc([]string{})
expect = "nil"
assert.Equal(t, expect, got)
got = zeroValueFunc(true)
expect = "false"
assert.Equal(t, expect, got)
got = zeroValueFunc(myType{})
expect = "(nero.myType{})"
assert.Equal(t, expect, got)
got = zeroValueFunc([1]int{1})
expect = "([1]int{})"
assert.Equal(t, expect, got)
got = zeroValueFunc([1][1]*myType{})
expect = "([1][1]*nero.myType{})"
assert.Equal(t, expect, got)
got = zeroValueFunc([0]interface{}{})
expect = "([0]interface {}{})"
assert.Equal(t, expect, got)
got = zeroValueFunc("")
expect = `""`
assert.Equal(t, expect, got)
})
t.Run("isType", func(t *testing.T) {
now := time.Now()
assert.True(t, isTypeFunc(now, "time.Time"))
assert.True(t, isTypeFunc(&now, "time.Time"))
})
assert.Len(t, prependToFields(&Field{}, []*Field{}), 1)
assert.NotEmpty(t, fileHeadersFunc())
}