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
|
package proto
import (
"math"
"testing"
"github.com/stretchr/testify/assert"
)
func TestInt128_Int(t *testing.T) {
for _, x := range []int{
math.MinInt,
-1000,
0,
1,
10,
42,
12345,
math.MaxInt,
} {
assert.Equal(t, x, Int128FromInt(x).Int())
}
assert.Equal(t, math.MaxInt, Int128{High: 1}.Int())
}
func TestInt128_UInt64(t *testing.T) {
for _, x := range []uint64{
0,
1,
10,
42,
12345,
math.MaxUint64,
} {
assert.Equal(t, x, Int128FromUInt64(x).UInt64())
}
assert.Equal(t, uint64(math.MaxUint64), Int128FromInt(-1).UInt64())
assert.Equal(t, uint64(math.MaxUint64), Int128{High: 1}.UInt64())
}
func TestUInt128_Int(t *testing.T) {
for _, x := range []int{
0,
1,
10,
42,
12345,
math.MaxInt,
} {
assert.Equal(t, x, UInt128FromInt(x).Int())
}
assert.Equal(t, -1, UInt128{High: 1}.Int())
}
func TestUInt128_UInt64(t *testing.T) {
for _, x := range []uint64{
0,
1,
10,
42,
12345,
math.MaxUint64,
} {
assert.Equal(t, x, UInt128FromUInt64(x).UInt64())
}
assert.Equal(t, uint64(math.MaxUint64), UInt128FromInt(-1).UInt64())
assert.Equal(t, uint64(math.MaxUint64), UInt128{High: 1}.UInt64())
}
|