(t *testing.T)
| 1041 | } |
| 1042 | |
| 1043 | func TestDecodeNumeric(t *testing.T) { |
| 1044 | tests := []struct { |
| 1045 | name string |
| 1046 | input duckdb.Decimal // will encode then decode |
| 1047 | expected string |
| 1048 | }{ |
| 1049 | {"99.99", duckdb.Decimal{Width: 10, Scale: 2, Value: big.NewInt(9999)}, "99.99"}, |
| 1050 | {"-50.25", duckdb.Decimal{Width: 10, Scale: 2, Value: big.NewInt(-5025)}, "-50.25"}, |
| 1051 | {"0.00", duckdb.Decimal{Width: 10, Scale: 2, Value: big.NewInt(0)}, "0.00"}, |
| 1052 | {"12.3456", duckdb.Decimal{Width: 8, Scale: 4, Value: big.NewInt(123456)}, "12.3456"}, |
| 1053 | {"0.0001", duckdb.Decimal{Width: 8, Scale: 4, Value: big.NewInt(1)}, "0.0001"}, |
| 1054 | {"9999.9999", duckdb.Decimal{Width: 8, Scale: 4, Value: big.NewInt(99999999)}, "9999.9999"}, |
| 1055 | {"10000.00", duckdb.Decimal{Width: 10, Scale: 2, Value: big.NewInt(1000000)}, "10000.00"}, |
| 1056 | {"1.00", duckdb.Decimal{Width: 10, Scale: 2, Value: big.NewInt(100)}, "1.00"}, |
| 1057 | } |
| 1058 | |
| 1059 | for _, tt := range tests { |
| 1060 | t.Run(tt.name, func(t *testing.T) { |
| 1061 | encoded := encodeNumeric(tt.input) |
| 1062 | decoded, err := decodeNumeric(encoded) |
| 1063 | if err != nil { |
| 1064 | t.Fatalf("decodeNumeric failed: %v", err) |
| 1065 | } |
| 1066 | if decoded != tt.expected { |
| 1067 | t.Errorf("decodeNumeric(encodeNumeric(%s)) = %q, want %q", tt.name, decoded, tt.expected) |
| 1068 | } |
| 1069 | }) |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | func TestUBIGINTTypmod(t *testing.T) { |
| 1074 | // UBIGINT should map to NUMERIC(20,0) with proper typmod |
nothing calls this directly
no test coverage detected