mirror of
https://github.com/rs/zerolog
synced 2026-06-08 17:13:30 +00:00
4685edb80b
This deprecates DurationFieldInteger in favor of DurationFieldFormat with the value of DurationFormatInt
31 lines
613 B
Go
31 lines
613 B
Go
package json
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestAppendKey(t *testing.T) {
|
|
want := make([]byte, 0)
|
|
want = append(want, []byte("{\"key\":")...)
|
|
|
|
got := enc.AppendKey([]byte("{"), "key") // test with empty object
|
|
if !bytes.Equal(got, want) {
|
|
t.Errorf("AppendKey(%v)\ngot: %s\nwant: %s",
|
|
"key",
|
|
string(got),
|
|
string(want))
|
|
}
|
|
|
|
want = make([]byte, 0)
|
|
want = append(want, []byte("},\"key\":")...) // test with non-empty object
|
|
|
|
got = enc.AppendKey([]byte("}"), "key")
|
|
if !bytes.Equal(got, want) {
|
|
t.Errorf("AppendKey(%v)\ngot: %s\nwant: %s",
|
|
"key",
|
|
string(got),
|
|
string(want))
|
|
}
|
|
}
|