-
Notifications
You must be signed in to change notification settings - Fork 11
/
fieldapi_test.go
129 lines (101 loc) · 2.64 KB
/
fieldapi_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 logr
import (
"errors"
"testing"
"time"
)
func TestFieldInt(t *testing.T) {
_ = Int("int", int(0))
type myInt int
_ = Int("int", myInt(0))
_ = Int("int8", int8(0))
type myInt8 int8
_ = Int("int8", myInt8(0))
_ = Int("int16", int16(0))
type myInt16 int16
_ = Int("int16", myInt16(0))
_ = Int("int32", int32(0))
type myInt32 int32
_ = Int("int32", myInt32(0))
_ = Int("int64", int64(0))
type myInt64 int64
_ = Int("int64", myInt64(0))
}
func TestFieldUint(t *testing.T) {
_ = Uint("uint", uint(0))
type myUint uint
_ = Uint("uint", myUint(0))
_ = Uint("uint8", uint8(0))
type myUint8 uint8
_ = Uint("uint8", myUint8(0))
_ = Uint("uint16", uint16(0))
type myUint16 uint16
_ = Uint("uint16", myUint16(0))
_ = Uint("uint32", uint32(0))
type myUint32 uint32
_ = Uint("uint32", myUint32(0))
_ = Uint("uint64", uint64(0))
type myUint64 uint64
_ = Uint("uint64", myUint64(0))
_ = Uint("uintptr", uintptr(0))
type myUintptr uintptr
_ = Uint("uintptr", myUintptr(0))
}
func TestFieldFloat(t *testing.T) {
_ = Float("float32", float32(0))
type myFloat32 float32
_ = Float("float32", myFloat32(0))
_ = Float("float64", float64(0))
type myFloat64 float32
_ = Float("float64", myFloat64(0))
}
func TestFieldString(t *testing.T) {
_ = String("string", "foo")
type myString string
_ = String("string", myString("foo"))
type myByteSlice string
_ = String("string", []byte{})
_ = String("string", myByteSlice([]byte{}))
}
func TestFieldStringer(t *testing.T) {
_ = Stringer("stringer", time.Now())
type myStringer = time.Time
_ = Stringer("stringer", myStringer(time.Now()))
}
func TestFieldErr(t *testing.T) {
_ = Err(errors.New("some error"))
type myError error
_ = Err(myError(errors.New("some error")))
}
func TestFieldNamedErr(t *testing.T) {
_ = NamedErr("named err", errors.New("some error"))
type myError error
_ = NamedErr("named err", myError(errors.New("some error")))
}
func TestFieldBool(t *testing.T) {
_ = Bool("bool", false)
type myBool bool
_ = Bool("bool", myBool(false))
}
func TestFieldDuration(t *testing.T) {
_ = Duration("duration", time.Duration(0))
}
func TestFieldMillis(t *testing.T) {
_ = Millis("millis", int64(0))
}
func TestFieldArray(t *testing.T) {
_ = Array("array", []string{})
_ = Array("array", []any{})
type myArray []any
_ = Array("array", myArray{})
type myGenericArray[T any] []T
_ = Array("array", myGenericArray[any]{})
}
func TestFieldMap(t *testing.T) {
_ = Map("array", map[string]any{})
_ = Map("array", map[int]any{})
type myMap map[string]string
_ = Map("array", myMap{})
type myGenericMap[K comparable, V any] map[K]V
_ = Map("array", myGenericMap[int, any]{})
}