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

Function TestEncodeInt8

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

Source from the content-addressed store, hash-verified

283}
284
285func TestEncodeInt8(t *testing.T) {
286 tests := []struct {
287 name string
288 input interface{}
289 expected int64
290 }{
291 {"int 42", int(42), 42},
292 {"int64 max", int64(9223372036854775807), 9223372036854775807},
293 {"int64 min", int64(-9223372036854775808), -9223372036854775808},
294 {"uint64 large", uint64(18446744073709551615), -1}, // wraps around
295 {"float64 1e10", float64(1e10), 10000000000},
296 }
297
298 for _, tt := range tests {
299 t.Run(tt.name, func(t *testing.T) {
300 result := encodeInt8(tt.input)
301 if result == nil {
302 t.Fatalf("encodeInt8(%v) returned nil", tt.input)
303 }
304 if len(result) != 8 {
305 t.Fatalf("encodeInt8(%v) length = %d, want 8", tt.input, len(result))
306 }
307 got := int64(binary.BigEndian.Uint64(result))
308 if got != tt.expected {
309 t.Errorf("encodeInt8(%v) = %d, want %d", tt.input, got, tt.expected)
310 }
311 })
312 }
313}
314
315func TestEncodeFloat4(t *testing.T) {
316 tests := []struct {

Callers

nothing calls this directly

Calls 2

encodeInt8Function · 0.85
RunMethod · 0.65

Tested by

no test coverage detected