-
Notifications
You must be signed in to change notification settings - Fork 0
/
int128_ispositive_test.go
88 lines (75 loc) · 1.41 KB
/
int128_ispositive_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
82
83
84
85
86
87
88
package bits128_test
import (
"testing"
"github.com/reiver/go-bits128"
)
func TestInt128_IsPositive(t *testing.T) {
tests := []struct{
Int128 bits128.Int128
Expected bool
}{
{
Int128: bits128.MinInt128(),
Expected: false,
},
{
Int128: bits128.Int128FromInt8(-5),
Expected: false,
},
{
Int128: bits128.Int128FromInt8(-4),
Expected: false,
},
{
Int128: bits128.Int128FromInt8(-3),
Expected: false,
},
{
Int128: bits128.Int128FromInt8(-2),
Expected: false,
},
{
Int128: bits128.Int128FromInt8(-1),
Expected: false,
},
{
Int128: bits128.Int128FromInt8(0),
Expected: false,
},
{
Int128: bits128.Int128FromInt8(1),
Expected: true,
},
{
Int128: bits128.Int128FromInt8(2),
Expected: true,
},
{
Int128: bits128.Int128FromInt8(3),
Expected: true,
},
{
Int128: bits128.Int128FromInt8(4),
Expected: true,
},
{
Int128: bits128.Int128FromInt8(5),
Expected: true,
},
{
Int128: bits128.MaxInt128(),
Expected: true,
},
}
for testNumber, test := range tests {
var actual bool = test.Int128.IsPositive()
var expected bool = test.Expected
if expected != actual {
t.Errorf("For test #%d, the actual is-positive value is not what was expected.", testNumber)
t.Logf("EXPECTED: %t", expected)
t.Logf("ACTUAL: %t", actual)
t.Logf("INT128: %s", test.Int128.HexString())
continue
}
}
}