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

Function TestEncodeDecodeUBIGINTMax

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

Source from the content-addressed store, hash-verified

1083}
1084
1085func TestEncodeDecodeUBIGINTMax(t *testing.T) {
1086 // Max UBIGINT = 2^64 - 1 = 18446744073709551615 (20 digits)
1087 // DuckDB Go driver returns UBIGINT as duckdb.Decimal with scale 0
1088 maxUBIGINT := new(big.Int)
1089 maxUBIGINT.SetString("18446744073709551615", 10)
1090 dec := duckdb.Decimal{Width: 20, Scale: 0, Value: maxUBIGINT}
1091
1092 encoded := encodeNumeric(dec)
1093 if encoded == nil {
1094 t.Fatal("encodeNumeric returned nil for max UBIGINT")
1095 }
1096
1097 decoded, err := decodeNumeric(encoded)
1098 if err != nil {
1099 t.Fatalf("decodeNumeric failed: %v", err)
1100 }
1101 if decoded != "18446744073709551615" {
1102 t.Errorf("roundtrip max UBIGINT = %q, want %q", decoded, "18446744073709551615")
1103 }
1104}
1105
1106func TestDecodeNumericRaw(t *testing.T) {
1107 // Test decoding a manually constructed binary numeric: 99.99

Callers

nothing calls this directly

Calls 2

encodeNumericFunction · 0.85
decodeNumericFunction · 0.85

Tested by

no test coverage detected