...
1 package pgtype_test
2
3 import (
4 "context"
5 "testing"
6
7 "github.com/jackc/pgx/v5/pgtype"
8 "github.com/jackc/pgx/v5/pgxtest"
9 )
10
11 func TestTIDCodec(t *testing.T) {
12 skipCockroachDB(t, "Server does not support type tid")
13
14 pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, nil, "tid", []pgxtest.ValueRoundTripTest{
15 {
16 pgtype.TID{BlockNumber: 42, OffsetNumber: 43, Valid: true},
17 new(pgtype.TID),
18 isExpectedEq(pgtype.TID{BlockNumber: 42, OffsetNumber: 43, Valid: true}),
19 },
20 {
21 pgtype.TID{BlockNumber: 4294967295, OffsetNumber: 65535, Valid: true},
22 new(pgtype.TID),
23 isExpectedEq(pgtype.TID{BlockNumber: 4294967295, OffsetNumber: 65535, Valid: true}),
24 },
25 {
26 pgtype.TID{BlockNumber: 42, OffsetNumber: 43, Valid: true},
27 new(string),
28 isExpectedEq("(42,43)"),
29 },
30 {
31 pgtype.TID{BlockNumber: 4294967295, OffsetNumber: 65535, Valid: true},
32 new(string),
33 isExpectedEq("(4294967295,65535)"),
34 },
35 {pgtype.TID{}, new(pgtype.TID), isExpectedEq(pgtype.TID{})},
36 {nil, new(pgtype.TID), isExpectedEq(pgtype.TID{})},
37 })
38 }
39
View as plain text