-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathline_test.go
58 lines (52 loc) · 1.34 KB
/
line_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package pgtype_test
import (
"context"
"testing"
pgx "github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jackc/pgx/v5/pgxtest"
)
func TestLineTranscode(t *testing.T) {
ctr := defaultConnTestRunner
ctr.AfterConnect = func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
pgxtest.SkipCockroachDB(t, conn, "Server does not support type line")
if _, ok := conn.TypeMap().TypeForName("line"); !ok {
t.Skip("Skipping due to no line type")
}
// line may exist but not be usable on 9.3 :(
var isPG93 bool
err := conn.QueryRow(context.Background(), "select version() ~ '9.3'").Scan(&isPG93)
if err != nil {
t.Fatal(err)
}
if isPG93 {
t.Skip("Skipping due to unimplemented line type in PG 9.3")
}
}
pgxtest.RunValueRoundTripTests(context.Background(), t, ctr, nil, "line", []pgxtest.ValueRoundTripTest{
{
pgtype.Line{
A: 1.23, B: 4.56, C: 7.89012345,
Valid: true,
},
new(pgtype.Line),
isExpectedEq(pgtype.Line{
A: 1.23, B: 4.56, C: 7.89012345,
Valid: true,
}),
},
{
pgtype.Line{
A: -1.23, B: -4.56, C: -7.89,
Valid: true,
},
new(pgtype.Line),
isExpectedEq(pgtype.Line{
A: -1.23, B: -4.56, C: -7.89,
Valid: true,
}),
},
{pgtype.Line{}, new(pgtype.Line), isExpectedEq(pgtype.Line{})},
{nil, new(pgtype.Line), isExpectedEq(pgtype.Line{})},
})
}