...
1 package pgtype_test
2
3 import (
4 "testing"
5
6 "github.com/jackc/pgtype"
7 "github.com/jackc/pgtype/testutil"
8 )
9
10 func TestInt8rangeTranscode(t *testing.T) {
11 testutil.TestSuccessfulTranscode(t, "Int8range", []interface{}{
12 &pgtype.Int8range{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present},
13 &pgtype.Int8range{Lower: pgtype.Int8{Int: 1, Status: pgtype.Present}, Upper: pgtype.Int8{Int: 10, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present},
14 &pgtype.Int8range{Lower: pgtype.Int8{Int: -42, Status: pgtype.Present}, Upper: pgtype.Int8{Int: -5, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present},
15 &pgtype.Int8range{Lower: pgtype.Int8{Int: 1, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Unbounded, Status: pgtype.Present},
16 &pgtype.Int8range{Upper: pgtype.Int8{Int: 1, Status: pgtype.Present}, LowerType: pgtype.Unbounded, UpperType: pgtype.Exclusive, Status: pgtype.Present},
17 &pgtype.Int8range{Status: pgtype.Null},
18 })
19 }
20
21 func TestInt8rangeNormalize(t *testing.T) {
22 testutil.TestSuccessfulNormalize(t, []testutil.NormalizeTest{
23 {
24 SQL: "select Int8range(1, 10, '(]')",
25 Value: pgtype.Int8range{Lower: pgtype.Int8{Int: 2, Status: pgtype.Present}, Upper: pgtype.Int8{Int: 11, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present},
26 },
27 })
28 }
29
View as plain text