-
Notifications
You must be signed in to change notification settings - Fork 0
/
uint128_dec_test.go
187 lines (174 loc) · 8.05 KB
/
uint128_dec_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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package bits128_test
import (
"testing"
"github.com/reiver/go-bits128"
)
func TestUint128_Dec(t *testing.T) {
tests := []struct{
Value bits128.Uint128
Expected bits128.Uint128
}{
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000001,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000000,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000002,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000001,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000003,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000002,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000004,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000003,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000005,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000004,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000007,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000006,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000009,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000008,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000A,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000009,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000B,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000A,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000C,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000B,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000D,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000C,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000E,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000D,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000F,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000E,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000010,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000000F,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000011,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000010,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000012,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000011,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000013,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000012,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000014,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000013,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000015,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000014,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000016,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000015,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000017,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000016,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000018,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000017,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000019,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000018,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001A,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000019,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001B,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001A,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001C,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001B,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001D,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001C,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001E,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001D,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001F,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001E,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000020,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x000000000000001F,0x0000000000000000}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x825C99712043E01D,0xED7BA4708E54465E}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0x825C99712043E01C,0xED7BA4708E54465E}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFB,0xFFFFFFFFFFFFFFFF}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFA,0xFFFFFFFFFFFFFFFF}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFC,0xFFFFFFFFFFFFFFFF}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFB,0xFFFFFFFFFFFFFFFF}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFD,0xFFFFFFFFFFFFFFFF}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFC,0xFFFFFFFFFFFFFFFF}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFE,0xFFFFFFFFFFFFFFFF}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFD,0xFFFFFFFFFFFFFFFF}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFE,0xFFFFFFFFFFFFFFFF}),
},
{
Value: bits128.Uint128FromUintsLittleEndian([2]uint{0x0000000000000000,0x0000000000000000}),
Expected: bits128.Uint128FromUintsLittleEndian([2]uint{0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF}),
},
}
for testNumber, test := range tests {
var actual bits128.Uint128 = test.Value
actual.Dec()
{
expected := test.Expected
if expected != actual {
t.Errorf("For test #%d, the actual dec-value is not what was expected." , testNumber)
t.Logf("EXPECTED: %v", expected)
t.Logf("ACTUAL: %v", actual)
t.Logf("VALUE: %v", test.Value)
continue
}
}
}
}