...
1 package pgtype_test
2
3 import (
4 "context"
5 "testing"
6
7 "github.com/jackc/pgtype"
8 "github.com/jackc/pgtype/testutil"
9 )
10
11 func TestLineTranscode(t *testing.T) {
12 conn := testutil.MustConnectPgx(t)
13 if _, ok := conn.ConnInfo().DataTypeForName("line"); !ok {
14 t.Skip("Skipping due to no line type")
15 }
16
17
18 var isPG93 bool
19 err := conn.QueryRow(context.Background(), "select version() ~ '9.3'").Scan(&isPG93)
20 if err != nil {
21 t.Fatal(err)
22 }
23 if isPG93 {
24 t.Skip("Skipping due to unimplemented line type in PG 9.3")
25 }
26
27 testutil.TestSuccessfulTranscode(t, "line", []interface{}{
28 &pgtype.Line{
29 A: 1.23, B: 4.56, C: 7.89012345,
30 Status: pgtype.Present,
31 },
32 &pgtype.Line{
33 A: -1.23, B: -4.56, C: -7.89,
34 Status: pgtype.Present,
35 },
36 &pgtype.Line{Status: pgtype.Null},
37 })
38 }
39
View as plain text