-
Notifications
You must be signed in to change notification settings - Fork 112
/
int8_multirange_test.go
81 lines (77 loc) · 2.14 KB
/
int8_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 TestInt8multirangeTranscode(t *testing.T) {
testutil.TestSuccessfulTranscode(t, "int8multirange", []interface{}{
&pgtype.Int8multirange{
Ranges: nil,
Status: pgtype.Present,
},
&pgtype.Int8multirange{
Ranges: []pgtype.Int8range{
{
Lower: pgtype.Int8{Int: -543, Status: pgtype.Present},
Upper: pgtype.Int8{Int: 342, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Exclusive,
Status: pgtype.Present,
},
},
Status: pgtype.Present,
},
&pgtype.Int8multirange{
Ranges: []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,
},
{
Lower: pgtype.Int8{Int: 5, Status: pgtype.Present},
Upper: pgtype.Int8{Int: 42, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Exclusive,
Status: pgtype.Present,
},
{
Lower: pgtype.Int8{Int: 52, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Unbounded,
Status: pgtype.Present,
},
},
Status: pgtype.Present,
},
})
}
func TestInt8multirangeNormalize(t *testing.T) {
testutil.TestSuccessfulNormalize(t, []testutil.NormalizeTest{
{
SQL: "select int8multirange(int8range(1, 14, '(]'), int8range(20, 25, '()'))",
Value: pgtype.Int8multirange{
Ranges: []pgtype.Int8range{
{
Lower: pgtype.Int8{Int: 2, Status: pgtype.Present},
Upper: pgtype.Int8{Int: 15, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Exclusive,
Status: pgtype.Present,
},
{
Lower: pgtype.Int8{Int: 21, Status: pgtype.Present},
Upper: pgtype.Int8{Int: 25, Status: pgtype.Present},
LowerType: pgtype.Inclusive,
UpperType: pgtype.Exclusive,
Status: pgtype.Present,
},
},
Status: pgtype.Present,
},
},
})
}