mirror of
https://github.com/jackc/pgx.git
synced 2025-04-27 13:14:32 +00:00
Added ValueRoundTripTest to pgxtest Removed pgtype/testutil pgtype tests now run with all (applicable) query modes. This gives better coverage than before and revealed several bugs which are also fixed in this commit.
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package pgtype_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
"github.com/jackc/pgx/v5/pgxtest"
|
|
)
|
|
|
|
func TestTimeCodec(t *testing.T) {
|
|
pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, nil, "time", []pgxtest.ValueRoundTripTest{
|
|
{
|
|
pgtype.Time{Microseconds: 0, Valid: true},
|
|
new(pgtype.Time),
|
|
isExpectedEq(pgtype.Time{Microseconds: 0, Valid: true}),
|
|
},
|
|
{
|
|
pgtype.Time{Microseconds: 1, Valid: true},
|
|
new(pgtype.Time),
|
|
isExpectedEq(pgtype.Time{Microseconds: 1, Valid: true}),
|
|
},
|
|
{
|
|
pgtype.Time{Microseconds: 86399999999, Valid: true},
|
|
new(pgtype.Time),
|
|
isExpectedEq(pgtype.Time{Microseconds: 86399999999, Valid: true}),
|
|
},
|
|
{
|
|
pgtype.Time{Microseconds: 86400000000, Valid: true},
|
|
new(pgtype.Time),
|
|
isExpectedEq(pgtype.Time{Microseconds: 86400000000, Valid: true}),
|
|
},
|
|
{
|
|
time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
|
|
new(pgtype.Time),
|
|
isExpectedEq(pgtype.Time{Microseconds: 0, Valid: true}),
|
|
},
|
|
{
|
|
pgtype.Time{Microseconds: 0, Valid: true},
|
|
new(time.Time),
|
|
isExpectedEq(time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)),
|
|
},
|
|
{pgtype.Time{}, new(pgtype.Time), isExpectedEq(pgtype.Time{})},
|
|
{nil, new(pgtype.Time), isExpectedEq(pgtype.Time{})},
|
|
})
|
|
}
|