(t *testing.T)
| 290 | } |
| 291 | |
| 292 | func TestDecode(t *testing.T) { |
| 293 | tests := []struct { |
| 294 | typ oid.Oid |
| 295 | format format |
| 296 | in []byte |
| 297 | want any |
| 298 | wantErr string |
| 299 | }{ |
| 300 | {oid.T_char, formatText, []byte("hello world"), "hello world", ``}, |
| 301 | {oid.T_bpchar, formatText, []byte("hello world"), "hello world", ``}, |
| 302 | {oid.T_varchar, formatText, []byte("hello world"), "hello world", ``}, |
| 303 | {oid.T_text, formatText, []byte("hello world"), "hello world", ``}, |
| 304 | |
| 305 | {oid.T_uuid, formatBinary, []byte{0x12, 0x34}, ([]byte)(nil), `pq: unable to decode uuid; bad length: 2`}, |
| 306 | } |
| 307 | |
| 308 | for _, tt := range tests { |
| 309 | t.Run("", func(t *testing.T) { |
| 310 | have, err := decode(nil, tt.in, tt.typ, tt.format) |
| 311 | if !pqtest.ErrorContains(err, tt.wantErr) { |
| 312 | t.Fatalf("wrong error:\nhave: %s\nwant: %s", err, tt.wantErr) |
| 313 | } |
| 314 | if !reflect.DeepEqual(have, tt.want) { |
| 315 | t.Errorf("\nhave: %#v\nwant: %#v", have, tt.want) |
| 316 | } |
| 317 | }) |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | func TestEncodeBytea(t *testing.T) { |
| 322 | have, err := encode([]byte("\\x\x00\x01\x02\xFF\xFEabcdefg0123"), oid.T_bytea) |
nothing calls this directly
no test coverage detected
searching dependent graphs…