(t *testing.T)
| 594 | } |
| 595 | |
| 596 | func TestFieldsArraySingleElement(t *testing.T) { |
| 597 | out := &bytes.Buffer{} |
| 598 | log := New(out) |
| 599 | log.Log(). |
| 600 | Objects("obj", []LogObjectMarshaler{fixtureObj{"a", "z", 1}}). |
| 601 | ObjectsV("obj_v", fixtureObj{"A", "Z", 2}). |
| 602 | Strs("str", []string{"foo"}). |
| 603 | StrsV("str_v", "baz"). |
| 604 | Stringers("stringer", []fmt.Stringer{net.IP{127, 0, 0, 1}}). |
| 605 | StringersV("stringer_v", net.IPv6loopback). |
| 606 | Errs("err", []error{errors.New("some error")}). |
| 607 | Bools("bool", []bool{true}). |
| 608 | Ints("int", []int{1}). |
| 609 | Ints8("int8", []int8{2}). |
| 610 | Ints16("int16", []int16{3}). |
| 611 | Ints32("int32", []int32{4}). |
| 612 | Ints64("int64", []int64{5}). |
| 613 | Uints("uint", []uint{6}). |
| 614 | Uints8("uint8", []uint8{7}). |
| 615 | Uints16("uint16", []uint16{8}). |
| 616 | Uints32("uint32", []uint32{9}). |
| 617 | Uints64("uint64", []uint64{10}). |
| 618 | Floats32("float32", []float32{11}). |
| 619 | Floats64("float64", []float64{12}). |
| 620 | Durs("dur", []time.Duration{1 * time.Second}). |
| 621 | Times("time", []time.Time{{}}). |
| 622 | IPAddrs("ip", []net.IP{{192, 168, 0, 100}}). |
| 623 | IPPrefixes("pfx", []net.IPNet{{IP: net.IP{192, 168, 0, 100}, Mask: net.CIDRMask(24, 32)}}). |
| 624 | Msg("") |
| 625 | if got, want := decodeIfBinaryToString(out.Bytes()), `{"obj":[{"Pub":"a","Tag":"z","priv":1}],"obj_v":[{"Pub":"A","Tag":"Z","priv":2}],"str":["foo"],"str_v":["baz"],"stringer":["127.0.0.1"],"stringer_v":["::1"],"err":["some error"],"bool":[true],"int":[1],"int8":[2],"int16":[3],"int32":[4],"int64":[5],"uint":[6],"uint8":[7],"uint16":[8],"uint32":[9],"uint64":[10],"float32":[11],"float64":[12],"dur":[1000],"time":["0001-01-01T00:00:00Z"],"ip":["192.168.0.100"],"pfx":["192.168.0.100/24"]}`+"\n"; got != want { |
| 626 | t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want) |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | func TestFieldsArrayMultipleElement(t *testing.T) { |
| 631 | out := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected