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
|
package zeronull_test
import (
"testing"
"time"
"github.com/jackc/pgtype/testutil"
"github.com/jackc/pgtype/zeronull"
)
func TestTimestampTranscode(t *testing.T) {
testutil.TestSuccessfulTranscodeEqFunc(t, "timestamp", []interface{}{
(zeronull.Timestamp)(time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)),
(zeronull.Timestamp)(time.Time{}),
}, func(a, b interface{}) bool {
at := a.(zeronull.Timestamp)
bt := b.(zeronull.Timestamp)
return time.Time(at).Equal(time.Time(bt))
})
}
func TestTimestampConvertsGoZeroToNull(t *testing.T) {
testutil.TestGoZeroToNullConversion(t, "timestamp", (zeronull.Timestamp)(time.Time{}))
}
func TestTimestampConvertsNullToGoZero(t *testing.T) {
testutil.TestNullToGoZeroConversion(t, "timestamp", (zeronull.Timestamp)(time.Time{}))
}
|