forked from mailru/go-clickhouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_test.go
47 lines (41 loc) · 980 Bytes
/
types_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
package clickhouse
import (
"database/sql/driver"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestArray(t *testing.T) {
testCases := []struct {
value interface{}
expected driver.Value
}{
{[]int16{1, 2}, []byte("[1,2]")},
{[]int32{1, 2}, []byte("[1,2]")},
{[]int64{1, 2}, []byte("[1,2]")},
{[]uint16{1, 2}, []byte("[1,2]")},
{[]uint32{1, 2}, []byte("[1,2]")},
{[]uint64{1, 2}, []byte("[1,2]")},
{[]uint64{}, []byte("[]")},
}
for _, tc := range testCases {
dv, err := Array(tc.value).Value()
if assert.NoError(t, err) {
assert.Equal(t, tc.expected, dv)
}
}
}
func TestDate(t *testing.T) {
d := time.Date(2016, 4, 4, 0, 0, 0, 0, time.Local)
dv, err := Date(d).Value()
if assert.NoError(t, err) {
assert.Equal(t, []byte("'2016-04-04'"), dv)
}
}
func TestUInt64(t *testing.T) {
u := uint64(1) << 63
dv, err := UInt64(u).Value()
if assert.NoError(t, err) {
assert.Equal(t, []byte("9223372036854775808"), dv)
}
}