-
Notifications
You must be signed in to change notification settings - Fork 112
/
int4_multirange_test.go
81 lines (77 loc) · 2.14 KB
/
int4_multirange_test.go
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package pgtype_test
import (
"testing"
"github.com/jackc/pgtype"
"github.com/jackc/pgtype/testutil"
)
func TestInt4multirangeTranscode(t *testing.T) {
testutil.TestSuccessfulTranscode(t, "int4multirange", []interface{}{
&pgtype.Int4multirange{
Ranges: nil,
Status: pgtype.Present,
},
&pgtype.Int4multirange{
Ranges: []pgtype.Int4range{
{
Lower: pgtype.Int4{Int: -543, Status: pgtype.Present},
Upper: pgtype.Int4{Int: 342, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Exclusive,
Status: pgtype.Present,
},
},
Status: pgtype.Present,
},
&pgtype.Int4multirange{
Ranges: []pgtype.Int4range{
{
Lower: pgtype.Int4{Int: -42, Status: pgtype.Present},
Upper: pgtype.Int4{Int: -5, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Exclusive,
Status: pgtype.Present,
},
{
Lower: pgtype.Int4{Int: 5, Status: pgtype.Present},
Upper: pgtype.Int4{Int: 42, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Exclusive,
Status: pgtype.Present,
},
{
Lower: pgtype.Int4{Int: 52, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Unbounded,
Status: pgtype.Present,
},
},
Status: pgtype.Present,
},
})
}
func TestInt4multirangeNormalize(t *testing.T) {
testutil.TestSuccessfulNormalize(t, []testutil.NormalizeTest{
{
SQL: "select int4multirange(int4range(1, 14, '(]'), int4range(20, 25, '()'))",
Value: pgtype.Int4multirange{
Ranges: []pgtype.Int4range{
{
Lower: pgtype.Int4{Int: 2, Status: pgtype.Present},
Upper: pgtype.Int4{Int: 15, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Exclusive,
Status: pgtype.Present,
},
{
Lower: pgtype.Int4{Int: 21, Status: pgtype.Present},
Upper: pgtype.Int4{Int: 25, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Exclusive,
Status: pgtype.Present,
},
},
Status: pgtype.Present,
},
},
})
}