(t *testing.T)
| 463 | } |
| 464 | |
| 465 | func TestEncodeBytea(t *testing.T) { |
| 466 | tests := []struct { |
| 467 | name string |
| 468 | input interface{} |
| 469 | expected []byte |
| 470 | }{ |
| 471 | {"byte slice", []byte{0x01, 0x02, 0x03}, []byte{0x01, 0x02, 0x03}}, |
| 472 | {"empty byte slice", []byte{}, []byte{}}, |
| 473 | {"string", "hello", []byte("hello")}, |
| 474 | } |
| 475 | |
| 476 | for _, tt := range tests { |
| 477 | t.Run(tt.name, func(t *testing.T) { |
| 478 | result := encodeBytea(tt.input) |
| 479 | if len(result) != len(tt.expected) { |
| 480 | t.Errorf("encodeBytea(%v) length = %d, want %d", tt.input, len(result), len(tt.expected)) |
| 481 | return |
| 482 | } |
| 483 | for i, b := range result { |
| 484 | if b != tt.expected[i] { |
| 485 | t.Errorf("encodeBytea(%v)[%d] = %d, want %d", tt.input, i, b, tt.expected[i]) |
| 486 | } |
| 487 | } |
| 488 | }) |
| 489 | } |
| 490 | |
| 491 | // Test unsupported type returns nil |
| 492 | if result := encodeBytea(12345); result != nil { |
| 493 | t.Errorf("encodeBytea(int) should return nil") |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | func TestEncodeBinary(t *testing.T) { |
| 498 | // Test that encodeBinary dispatches to the correct encoder |
nothing calls this directly
no test coverage detected