MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestDecodeInt4

Function TestDecodeInt4

server/types_test.go:611–645  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

609}
610
611func 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
647func TestDecodeInt8(t *testing.T) {
648 tests := []struct {

Callers

nothing calls this directly

Calls 2

decodeInt4Function · 0.85
RunMethod · 0.65

Tested by

no test coverage detected