(t *testing.T)
| 344 | } |
| 345 | |
| 346 | func TestEncodeFloat8(t *testing.T) { |
| 347 | tests := []struct { |
| 348 | name string |
| 349 | input interface{} |
| 350 | expected float64 |
| 351 | }{ |
| 352 | {"float64 3.14159", float64(3.14159), 3.14159}, |
| 353 | {"float64 -1e100", float64(-1e100), -1e100}, |
| 354 | {"float32 2.5", float32(2.5), 2.5}, |
| 355 | {"int 42", int(42), 42.0}, |
| 356 | {"int64 1000000", int64(1000000), 1000000.0}, |
| 357 | } |
| 358 | |
| 359 | for _, tt := range tests { |
| 360 | t.Run(tt.name, func(t *testing.T) { |
| 361 | result := encodeFloat8(tt.input) |
| 362 | if result == nil { |
| 363 | t.Fatalf("encodeFloat8(%v) returned nil", tt.input) |
| 364 | } |
| 365 | if len(result) != 8 { |
| 366 | t.Fatalf("encodeFloat8(%v) length = %d, want 8", tt.input, len(result)) |
| 367 | } |
| 368 | bits := binary.BigEndian.Uint64(result) |
| 369 | got := math.Float64frombits(bits) |
| 370 | if got != tt.expected { |
| 371 | t.Errorf("encodeFloat8(%v) = %f, want %f", tt.input, got, tt.expected) |
| 372 | } |
| 373 | }) |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | func TestEncodeDate(t *testing.T) { |
| 378 | // PostgreSQL epoch is 2000-01-01 |
nothing calls this directly
no test coverage detected