(t *testing.T)
| 217 | } |
| 218 | |
| 219 | func 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 | |
| 252 | func TestAppendEmbeddedCBOR(t *testing.T) { |
| 253 | tests := []struct { |
nothing calls this directly
no test coverage detected