Skip to content

Commit a0674c8

Browse files
rabbbitsywhang
authored andcommitted
Add direct coverage to zap.Any (#1309)
Practically, the cases added are today covered by the tests for strongly typed functions, but are missing if someone was to do a refactoring like #1305 or #1307. More theoretically, since `zap.Any` is an external interface, IMO it makes sense to test it separately too.
1 parent 1310691 commit a0674c8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

field_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func TestFieldConstructors(t *testing.T) {
8686
uint16Val = uint16(1)
8787
uint8Val = uint8(1)
8888
uintptrVal = uintptr(1)
89+
nilErr error
8990
)
9091

9192
tests := []struct {
@@ -166,6 +167,7 @@ func TestFieldConstructors(t *testing.T) {
166167
{"Any:Uintptr", Any("k", uintptr(1)), Uintptr("k", 1)},
167168
{"Any:Uintptrs", Any("k", []uintptr{1}), Uintptrs("k", []uintptr{1})},
168169
{"Any:Time", Any("k", time.Unix(0, 0)), Time("k", time.Unix(0, 0))},
170+
{"Any:TimeFullType", Any("k", time.Time{}), Time("k", time.Time{})},
169171
{"Any:Times", Any("k", []time.Time{time.Unix(0, 0)}), Times("k", []time.Time{time.Unix(0, 0)})},
170172
{"Any:Duration", Any("k", time.Second), Duration("k", time.Second)},
171173
{"Any:Durations", Any("k", []time.Duration{time.Second}), Durations("k", []time.Duration{time.Second})},
@@ -222,6 +224,7 @@ func TestFieldConstructors(t *testing.T) {
222224
{"Ptr:Time", Timep("k", &timeVal), Time("k", timeVal)},
223225
{"Any:PtrTime", Any("k", (*time.Time)(nil)), nilField("k")},
224226
{"Any:PtrTime", Any("k", &timeVal), Time("k", timeVal)},
227+
{"Any:PtrTimeFullType", Any("k", &time.Time{}), Time("k", time.Time{})},
225228
{"Ptr:Uint", Uintp("k", nil), nilField("k")},
226229
{"Ptr:Uint", Uintp("k", &uintVal), Uint("k", uintVal)},
227230
{"Any:PtrUint", Any("k", (*uint)(nil)), nilField("k")},
@@ -246,6 +249,7 @@ func TestFieldConstructors(t *testing.T) {
246249
{"Ptr:Uintptr", Uintptrp("k", &uintptrVal), Uintptr("k", uintptrVal)},
247250
{"Any:PtrUintptr", Any("k", (*uintptr)(nil)), nilField("k")},
248251
{"Any:PtrUintptr", Any("k", &uintptrVal), Uintptr("k", uintptrVal)},
252+
{"Any:ErrorNil", Any("k", nilErr), nilField("k")},
249253
{"Namespace", Namespace("k"), Field{Key: "k", Type: zapcore.NamespaceType}},
250254
}
251255

0 commit comments

Comments
 (0)