pgx/pgtype/box_test.go
Jack Christensen ee93440ac1 pgtype uses pgxtest
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.
2022-04-02 14:34:19 -05:00

41 lines
945 B
Go

package pgtype_test
import (
"context"
"testing"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jackc/pgx/v5/pgxtest"
)
func TestBoxCodec(t *testing.T) {
skipCockroachDB(t, "Server does not support box type")
pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, nil, "box", []pgxtest.ValueRoundTripTest{
{
pgtype.Box{
P: [2]pgtype.Vec2{{7.1, 5.2345678}, {3.14, 1.678}},
Valid: true,
},
new(pgtype.Box),
isExpectedEq(pgtype.Box{
P: [2]pgtype.Vec2{{7.1, 5.2345678}, {3.14, 1.678}},
Valid: true,
}),
},
{
pgtype.Box{
P: [2]pgtype.Vec2{{7.1, 5.2345678}, {-13.14, -5.234}},
Valid: true,
},
new(pgtype.Box),
isExpectedEq(pgtype.Box{
P: [2]pgtype.Vec2{{7.1, 5.2345678}, {-13.14, -5.234}},
Valid: true,
}),
},
{pgtype.Box{}, new(pgtype.Box), isExpectedEq(pgtype.Box{})},
{nil, new(pgtype.Box), isExpectedEq(pgtype.Box{})},
})
}