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

Function TestDecodeObjectToStr

internal/cbor/decoder_test.go:327–358  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

325}
326
327func TestDecodeObjectToStr(t *testing.T) {
328 tests := []struct {
329 name string
330 input []byte
331 want string
332 }{
333 {
334 name: "non-binary input",
335 input: []byte(`{"key":"value"}`),
336 want: `{"key":"value"}`,
337 },
338 {
339 name: "binary input - simple object",
340 input: []byte("\xbf\x64IETF\x20\xff"), // {"IETF": -1} in indefinite length CBOR
341 want: "{\"IETF\":-1}",
342 },
343 {
344 name: "binary input - array",
345 input: []byte("\x84\x20\x00\x18\xc8\x14"), // [-1, 0, 200, 20]
346 want: "[-1,0,200,20]",
347 },
348 }
349
350 for _, tt := range tests {
351 t.Run(tt.name, func(t *testing.T) {
352 got := DecodeObjectToStr(tt.input)
353 if got != tt.want {
354 t.Errorf("DecodeObjectToStr() = %q, want %q", got, tt.want)
355 }
356 })
357 }
358}
359
360func TestDecodeIfBinaryToBytes(t *testing.T) {
361 tests := []struct {

Callers

nothing calls this directly

Calls 2

DecodeObjectToStrFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected