(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestArray(t *testing.T) { |
| 11 | a := Arr(). |
| 12 | Bool(true). |
| 13 | Int(1). |
| 14 | Int8(2). |
| 15 | Int16(3). |
| 16 | Int32(4). |
| 17 | Int64(5). |
| 18 | Uint(6). |
| 19 | Uint8(7). |
| 20 | Uint16(8). |
| 21 | Uint32(9). |
| 22 | Uint64(10). |
| 23 | Float32(11.98122). |
| 24 | Float64(12.987654321). |
| 25 | Str("a"). |
| 26 | Bytes([]byte("b")). |
| 27 | Hex([]byte{0x1f}). |
| 28 | RawJSON([]byte(`{"some":"json"}`)). |
| 29 | RawJSON([]byte(`{"longer":[1111,2222,3333,4444,5555]}`)). |
| 30 | Time(time.Time{}). |
| 31 | IPAddr(net.IP{192, 168, 0, 10}). |
| 32 | IPPrefix(net.IPNet{IP: net.IP{127, 0, 0, 0}, Mask: net.CIDRMask(24, 32)}). |
| 33 | MACAddr(net.HardwareAddr{0x01, 0x23, 0x45, 0x67, 0x89, 0xab}). |
| 34 | Interface(struct { |
| 35 | Pub string |
| 36 | Tag string `json:"tag"` |
| 37 | priv int |
| 38 | }{"A", "j", -5}). |
| 39 | Interface(logObjectMarshalerImpl{ |
| 40 | name: "ZOT", |
| 41 | age: 35, |
| 42 | }). |
| 43 | Dur(0). |
| 44 | Dict(Dict(). |
| 45 | Str("bar", "baz"). |
| 46 | Int("n", 1), |
| 47 | ). |
| 48 | Err(nil). |
| 49 | Err(fmt.Errorf("failure")). |
| 50 | Err(loggableError{fmt.Errorf("oops")}). |
| 51 | Object(logObjectMarshalerImpl{ |
| 52 | name: "ZIT", |
| 53 | age: 22, |
| 54 | }). |
| 55 | Type(3.14) |
| 56 | |
| 57 | want := `[true,1,2,3,4,5,6,7,8,9,10,11.98122,12.987654321,"a","b","1f",{"some":"json"},{"longer":[1111,2222,3333,4444,5555]},"0001-01-01T00:00:00Z","192.168.0.10","127.0.0.0/24","01:23:45:67:89:ab",{"Pub":"A","tag":"j"},{"name":"zot","age":-35},0,{"bar":"baz","n":1},null,"failure",{"l":"OOPS"},{"name":"zit","age":-22},"float64"]` |
| 58 | if got := decodeObjectToStr(a.write([]byte{})); got != want { |
| 59 | t.Errorf("Array.write()\ngot: %s\nwant: %s", got, want) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func TestArray_MarshalZerologArray(t *testing.T) { |
| 64 | a := Arr() |
nothing calls this directly
no test coverage detected