(t *testing.T)
| 283 | } |
| 284 | |
| 285 | func 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 | |
| 315 | func TestEncodeFloat4(t *testing.T) { |
| 316 | tests := []struct { |
nothing calls this directly
no test coverage detected