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

Function TestDecodeBool

server/types_test.go:542–573  ·  view source on GitHub ↗

Tests for binary parameter decoding functions

(t *testing.T)

Source from the content-addressed store, hash-verified

540// Tests for binary parameter decoding functions
541
542func TestDecodeBool(t *testing.T) {
543 tests := []struct {
544 name string
545 input []byte
546 expected bool
547 wantErr bool
548 }{
549 {"true", []byte{1}, true, false},
550 {"false", []byte{0}, false, false},
551 {"non-zero is true", []byte{42}, true, false},
552 {"empty data", []byte{}, false, true},
553 }
554
555 for _, tt := range tests {
556 t.Run(tt.name, func(t *testing.T) {
557 result, err := decodeBool(tt.input)
558 if tt.wantErr {
559 if err == nil {
560 t.Errorf("decodeBool(%v) expected error, got nil", tt.input)
561 }
562 return
563 }
564 if err != nil {
565 t.Errorf("decodeBool(%v) unexpected error: %v", tt.input, err)
566 return
567 }
568 if result != tt.expected {
569 t.Errorf("decodeBool(%v) = %v, want %v", tt.input, result, tt.expected)
570 }
571 })
572 }
573}
574
575func TestDecodeInt2(t *testing.T) {
576 tests := []struct {

Callers

nothing calls this directly

Calls 2

decodeBoolFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected