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

Function TestAppendEmbeddedJSON

internal/cbor/string_test.go:219–250  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

217}
218
219func TestAppendEmbeddedJSON(t *testing.T) {
220 tests := []struct {
221 name string
222 input []byte
223 want string
224 }{
225 {
226 name: "empty JSON",
227 input: []byte{},
228 want: "\xd9\x01\x06@", // tag 0xd9 + empty byte string
229 },
230 {
231 name: "small JSON",
232 input: []byte(`{"key":"value"}`),
233 want: "\xd9\x01\x06O{\"key\":\"value\"}", // tag 0xd9 + byte string with content
234 },
235 {
236 name: "large JSON (>23 bytes)",
237 input: []byte(`{"key":"this is a very long value that exceeds the 23 byte limit for direct encoding"}`),
238 want: "\xd9\x01\x06XV{\"key\":\"this is a very long value that exceeds the 23 byte limit for direct encoding\"}",
239 },
240 }
241
242 for _, tt := range tests {
243 t.Run(tt.name, func(t *testing.T) {
244 got := AppendEmbeddedJSON([]byte{}, tt.input)
245 if string(got) != tt.want {
246 t.Errorf("AppendEmbeddedJSON() = %q, want %q", string(got), tt.want)
247 }
248 })
249 }
250}
251
252func TestAppendEmbeddedCBOR(t *testing.T) {
253 tests := []struct {

Callers

nothing calls this directly

Calls 2

AppendEmbeddedJSONFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected