(t *testing.T)
| 53 | } |
| 54 | |
| 55 | func TestArrayWrappers(t *testing.T) { |
| 56 | tests := []struct { |
| 57 | desc string |
| 58 | field Field |
| 59 | expected []interface{} |
| 60 | }{ |
| 61 | {"empty bools", Bools("", []bool{}), []interface{}{}}, |
| 62 | {"empty byte strings", ByteStrings("", [][]byte{}), []interface{}{}}, |
| 63 | {"empty complex128s", Complex128s("", []complex128{}), []interface{}{}}, |
| 64 | {"empty complex64s", Complex64s("", []complex64{}), []interface{}{}}, |
| 65 | {"empty durations", Durations("", []time.Duration{}), []interface{}{}}, |
| 66 | {"empty float64s", Float64s("", []float64{}), []interface{}{}}, |
| 67 | {"empty float32s", Float32s("", []float32{}), []interface{}{}}, |
| 68 | {"empty ints", Ints("", []int{}), []interface{}{}}, |
| 69 | {"empty int64s", Int64s("", []int64{}), []interface{}{}}, |
| 70 | {"empty int32s", Int32s("", []int32{}), []interface{}{}}, |
| 71 | {"empty int16s", Int16s("", []int16{}), []interface{}{}}, |
| 72 | {"empty int8s", Int8s("", []int8{}), []interface{}{}}, |
| 73 | {"empty strings", Strings("", []string{}), []interface{}{}}, |
| 74 | {"empty times", Times("", []time.Time{}), []interface{}{}}, |
| 75 | {"empty uints", Uints("", []uint{}), []interface{}{}}, |
| 76 | {"empty uint64s", Uint64s("", []uint64{}), []interface{}{}}, |
| 77 | {"empty uint32s", Uint32s("", []uint32{}), []interface{}{}}, |
| 78 | {"empty uint16s", Uint16s("", []uint16{}), []interface{}{}}, |
| 79 | {"empty uint8s", Uint8s("", []uint8{}), []interface{}{}}, |
| 80 | {"empty uintptrs", Uintptrs("", []uintptr{}), []interface{}{}}, |
| 81 | {"bools", Bools("", []bool{true, false}), []interface{}{true, false}}, |
| 82 | {"byte strings", ByteStrings("", [][]byte{{1, 2}, {3, 4}}), []interface{}{"\x01\x02", "\x03\x04"}}, |
| 83 | {"complex128s", Complex128s("", []complex128{1 + 2i, 3 + 4i}), []interface{}{1 + 2i, 3 + 4i}}, |
| 84 | {"complex64s", Complex64s("", []complex64{1 + 2i, 3 + 4i}), []interface{}{complex64(1 + 2i), complex64(3 + 4i)}}, |
| 85 | {"durations", Durations("", []time.Duration{1, 2}), []interface{}{time.Nanosecond, 2 * time.Nanosecond}}, |
| 86 | {"float64s", Float64s("", []float64{1.2, 3.4}), []interface{}{1.2, 3.4}}, |
| 87 | {"float32s", Float32s("", []float32{1.2, 3.4}), []interface{}{float32(1.2), float32(3.4)}}, |
| 88 | {"ints", Ints("", []int{1, 2}), []interface{}{1, 2}}, |
| 89 | {"int64s", Int64s("", []int64{1, 2}), []interface{}{int64(1), int64(2)}}, |
| 90 | {"int32s", Int32s("", []int32{1, 2}), []interface{}{int32(1), int32(2)}}, |
| 91 | {"int16s", Int16s("", []int16{1, 2}), []interface{}{int16(1), int16(2)}}, |
| 92 | {"int8s", Int8s("", []int8{1, 2}), []interface{}{int8(1), int8(2)}}, |
| 93 | {"strings", Strings("", []string{"foo", "bar"}), []interface{}{"foo", "bar"}}, |
| 94 | {"times", Times("", []time.Time{time.Unix(0, 0), time.Unix(0, 0)}), []interface{}{time.Unix(0, 0), time.Unix(0, 0)}}, |
| 95 | {"uints", Uints("", []uint{1, 2}), []interface{}{uint(1), uint(2)}}, |
| 96 | {"uint64s", Uint64s("", []uint64{1, 2}), []interface{}{uint64(1), uint64(2)}}, |
| 97 | {"uint32s", Uint32s("", []uint32{1, 2}), []interface{}{uint32(1), uint32(2)}}, |
| 98 | {"uint16s", Uint16s("", []uint16{1, 2}), []interface{}{uint16(1), uint16(2)}}, |
| 99 | {"uint8s", Uint8s("", []uint8{1, 2}), []interface{}{uint8(1), uint8(2)}}, |
| 100 | {"uintptrs", Uintptrs("", []uintptr{1, 2}), []interface{}{uintptr(1), uintptr(2)}}, |
| 101 | } |
| 102 | |
| 103 | for _, tt := range tests { |
| 104 | enc := zapcore.NewMapObjectEncoder() |
| 105 | tt.field.Key = "k" |
| 106 | tt.field.AddTo(enc) |
| 107 | assert.Equal(t, tt.expected, enc.Fields["k"], "%s: unexpected map contents.", tt.desc) |
| 108 | assert.Equal(t, 1, len(enc.Fields), "%s: found extra keys in map: %v", tt.desc, enc.Fields) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | func TestObjectsAndObjectValues(t *testing.T) { |
nothing calls this directly
no test coverage detected