(t *testing.T)
| 609 | } |
| 610 | |
| 611 | func TestDecodeInt4(t *testing.T) { |
| 612 | tests := []struct { |
| 613 | name string |
| 614 | input []byte |
| 615 | expected int32 |
| 616 | wantErr bool |
| 617 | }{ |
| 618 | {"positive", []byte{0x00, 0x00, 0x00, 0x2A}, 42, false}, |
| 619 | {"negative", []byte{0xFF, 0xFF, 0xFF, 0xFF}, -1, false}, |
| 620 | {"max", []byte{0x7F, 0xFF, 0xFF, 0xFF}, 2147483647, false}, |
| 621 | {"min", []byte{0x80, 0x00, 0x00, 0x00}, -2147483648, false}, |
| 622 | {"zero", []byte{0x00, 0x00, 0x00, 0x00}, 0, false}, |
| 623 | {"insufficient data", []byte{0x00, 0x00}, 0, true}, |
| 624 | {"empty data", []byte{}, 0, true}, |
| 625 | } |
| 626 | |
| 627 | for _, tt := range tests { |
| 628 | t.Run(tt.name, func(t *testing.T) { |
| 629 | result, err := decodeInt4(tt.input) |
| 630 | if tt.wantErr { |
| 631 | if err == nil { |
| 632 | t.Errorf("decodeInt4(%v) expected error, got nil", tt.input) |
| 633 | } |
| 634 | return |
| 635 | } |
| 636 | if err != nil { |
| 637 | t.Errorf("decodeInt4(%v) unexpected error: %v", tt.input, err) |
| 638 | return |
| 639 | } |
| 640 | if result != tt.expected { |
| 641 | t.Errorf("decodeInt4(%v) = %d, want %d", tt.input, result, tt.expected) |
| 642 | } |
| 643 | }) |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | func TestDecodeInt8(t *testing.T) { |
| 648 | tests := []struct { |
nothing calls this directly
no test coverage detected