(t *testing.T)
| 645 | } |
| 646 | |
| 647 | func TestDecodeInt8(t *testing.T) { |
| 648 | tests := []struct { |
| 649 | name string |
| 650 | input []byte |
| 651 | expected int64 |
| 652 | wantErr bool |
| 653 | }{ |
| 654 | {"positive", []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A}, 42, false}, |
| 655 | {"negative", []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, -1, false}, |
| 656 | {"max", []byte{0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 9223372036854775807, false}, |
| 657 | {"min", []byte{0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, -9223372036854775808, false}, |
| 658 | {"zero", []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0, false}, |
| 659 | {"insufficient data", []byte{0x00, 0x00, 0x00, 0x00}, 0, true}, |
| 660 | {"empty data", []byte{}, 0, true}, |
| 661 | } |
| 662 | |
| 663 | for _, tt := range tests { |
| 664 | t.Run(tt.name, func(t *testing.T) { |
| 665 | result, err := decodeInt8(tt.input) |
| 666 | if tt.wantErr { |
| 667 | if err == nil { |
| 668 | t.Errorf("decodeInt8(%v) expected error, got nil", tt.input) |
| 669 | } |
| 670 | return |
| 671 | } |
| 672 | if err != nil { |
| 673 | t.Errorf("decodeInt8(%v) unexpected error: %v", tt.input, err) |
| 674 | return |
| 675 | } |
| 676 | if result != tt.expected { |
| 677 | t.Errorf("decodeInt8(%v) = %d, want %d", tt.input, result, tt.expected) |
| 678 | } |
| 679 | }) |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | func TestDecodeFloat4(t *testing.T) { |
| 684 | tests := []struct { |
nothing calls this directly
no test coverage detected