...
1 package zeronull_test
2
3 import (
4 "testing"
5 "time"
6
7 "github.com/jackc/pgtype/testutil"
8 "github.com/jackc/pgtype/zeronull"
9 )
10
11 func TestTimestamptzTranscode(t *testing.T) {
12 testutil.TestSuccessfulTranscodeEqFunc(t, "timestamptz", []interface{}{
13 (zeronull.Timestamptz)(time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)),
14 (zeronull.Timestamptz)(time.Time{}),
15 }, func(a, b interface{}) bool {
16 at := a.(zeronull.Timestamptz)
17 bt := b.(zeronull.Timestamptz)
18
19 return time.Time(at).Equal(time.Time(bt))
20 })
21 }
22
23 func TestTimestamptzConvertsGoZeroToNull(t *testing.T) {
24 testutil.TestGoZeroToNullConversion(t, "timestamptz", (zeronull.Timestamptz)(time.Time{}))
25 }
26
27 func TestTimestamptzConvertsNullToGoZero(t *testing.T) {
28 testutil.TestNullToGoZeroConversion(t, "timestamptz", (zeronull.Timestamptz)(time.Time{}))
29 }
30
View as plain text