(t *testing.T)
| 325 | } |
| 326 | |
| 327 | func 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 | |
| 360 | func TestDecodeIfBinaryToBytes(t *testing.T) { |
| 361 | tests := []struct { |
nothing calls this directly
no test coverage detected