-
Notifications
You must be signed in to change notification settings - Fork 0
/
gt_null_int_test.go
37 lines (33 loc) · 1019 Bytes
/
gt_null_int_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
package gt_test
import (
"testing"
"github.com/mitranim/gt"
)
// TODO: test various invalid inputs.
func TestNullInt(t *testing.T) {
t.Run(`Decodable/sql.Scanner`, func(t *testing.T) {
var (
primZero = int64(0)
primNonZero = int64(123)
zero = gt.NullInt(primZero)
nonZero = gt.NullInt(primNonZero)
dec = new(gt.NullInt)
)
t.Run(`int`, func(t *testing.T) {
testScanEmpty(t, zero, nonZero, dec, int(primZero))
testScanNonEmpty(t, zero, nonZero, dec, int(primNonZero))
})
t.Run(`int8`, func(t *testing.T) {
testScanEmpty(t, zero, nonZero, dec, int8(primZero))
testScanNonEmpty(t, zero, nonZero, dec, int8(primNonZero))
})
t.Run(`int16`, func(t *testing.T) {
testScanEmpty(t, zero, nonZero, dec, int16(primZero))
testScanNonEmpty(t, zero, nonZero, dec, int16(primNonZero))
})
t.Run(`int32`, func(t *testing.T) {
testScanEmpty(t, zero, nonZero, dec, int32(primZero))
testScanNonEmpty(t, zero, nonZero, dec, int32(primNonZero))
})
})
}