MCPcopy
hub / github.com/rs/zerolog / TestAppendKey

Function TestAppendKey

internal/json/base_test.go:8–30  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestAppendKey(t *testing.T) {
9 want := make([]byte, 0)
10 want = append(want, []byte("{\"key\":")...)
11
12 got := enc.AppendKey([]byte("{"), "key") // test with empty object
13 if !bytes.Equal(got, want) {
14 t.Errorf("AppendKey(%v)\ngot: %s\nwant: %s",
15 "key",
16 string(got),
17 string(want))
18 }
19
20 want = make([]byte, 0)
21 want = append(want, []byte("},\"key\":")...) // test with non-empty object
22
23 got = enc.AppendKey([]byte("}"), "key")
24 if !bytes.Equal(got, want) {
25 t.Errorf("AppendKey(%v)\ngot: %s\nwant: %s",
26 "key",
27 string(got),
28 string(want))
29 }
30}

Callers

nothing calls this directly

Calls 1

AppendKeyMethod · 0.65

Tested by

no test coverage detected