-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathint_end_conversion_test.go
65 lines (58 loc) · 1.22 KB
/
int_end_conversion_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
package sdk
import "testing"
func TestCanOverflowChecks32Bits(t *testing.T) {
if !is32Bit {
t.Skip("Not running on a 64-bit machine!")
}
cases := []struct {
endKind string
wantOverflow bool
}{
{"int8", true},
{"int16", true},
{"int32", false},
{"int64", false},
{"int", false},
{"uint8", true},
{"uint16", true},
{"uint32", false},
{"uint64", false},
{"uint", false},
}
for _, tt := range cases {
tt := tt
t.Run(tt.endKind, func(t *testing.T) {
if got := canLenOverflow32(tt.endKind); got != tt.wantOverflow {
t.Fatalf("Mismatch\n\tGot: %t\n\tWant:%t", got, tt.wantOverflow)
}
})
}
}
func TestCanOverflowChecks64Bits(t *testing.T) {
if is32Bit {
t.Skip("Not running on a 32-bit machine!")
}
cases := []struct {
endKind string
wantOverflow bool
}{
{"int8", true},
{"int16", true},
{"int32", true},
{"int", false},
{"int64", false},
{"uint8", true},
{"uint16", true},
{"uint32", true},
{"uint64", false},
{"uint", false},
}
for _, tt := range cases {
tt := tt
t.Run(tt.endKind, func(t *testing.T) {
if got := canLenOverflow64(tt.endKind); got != tt.wantOverflow {
t.Fatalf("Mismatch\n\tGot: %t\n\tWant:%t", got, tt.wantOverflow)
}
})
}
}