@@ -21,8 +21,6 @@ import (
21
21
"encoding/hex"
22
22
"math/big"
23
23
"testing"
24
-
25
- "github.com/XinFinOrg/XDPoSChain/common"
26
24
)
27
25
28
26
func TestHexOrDecimal256 (t * testing.T ) {
@@ -100,23 +98,6 @@ func TestBigMin(t *testing.T) {
100
98
}
101
99
}
102
100
103
- func TestFirstBigSet (t * testing.T ) {
104
- tests := []struct {
105
- num * big.Int
106
- ix int
107
- }{
108
- {big .NewInt (0 ), 0 },
109
- {big .NewInt (1 ), 0 },
110
- {big .NewInt (2 ), 1 },
111
- {big .NewInt (0x100 ), 8 },
112
- }
113
- for _ , test := range tests {
114
- if ix := FirstBitSet (test .num ); ix != test .ix {
115
- t .Errorf ("FirstBitSet(b%b) = %d, want %d" , test .num , ix , test .ix )
116
- }
117
- }
118
- }
119
-
120
101
func TestPaddedBigBytes (t * testing.T ) {
121
102
tests := []struct {
122
103
num * big.Int
@@ -156,20 +137,6 @@ func BenchmarkPaddedBigBytesSmallOnePadding(b *testing.B) {
156
137
}
157
138
}
158
139
159
- func BenchmarkByteAtBrandNew (b * testing.B ) {
160
- bigint := MustParseBig256 ("0x18F8F8F1000111000110011100222004330052300000000000000000FEFCF3CC" )
161
- for i := 0 ; i < b .N ; i ++ {
162
- bigEndianByteAt (bigint , 15 )
163
- }
164
- }
165
-
166
- func BenchmarkByteAt (b * testing.B ) {
167
- bigint := MustParseBig256 ("0x18F8F8F1000111000110011100222004330052300000000000000000FEFCF3CC" )
168
- for i := 0 ; i < b .N ; i ++ {
169
- bigEndianByteAt (bigint , 15 )
170
- }
171
- }
172
-
173
140
func BenchmarkByteAtOld (b * testing.B ) {
174
141
bigint := MustParseBig256 ("0x18F8F8F1000111000110011100222004330052300000000000000000FEFCF3CC" )
175
142
for i := 0 ; i < b .N ; i ++ {
@@ -220,61 +187,3 @@ func TestU256Bytes(t *testing.T) {
220
187
t .Errorf ("expected %x got %x" , ubytes , unsigned )
221
188
}
222
189
}
223
-
224
- func TestBigEndianByteAt (t * testing.T ) {
225
- tests := []struct {
226
- x string
227
- y int
228
- exp byte
229
- }{
230
- {"00" , 0 , 0x00 },
231
- {"01" , 1 , 0x00 },
232
- {"00" , 1 , 0x00 },
233
- {"01" , 0 , 0x01 },
234
- {"0000000000000000000000000000000000000000000000000000000000102030" , 0 , 0x30 },
235
- {"0000000000000000000000000000000000000000000000000000000000102030" , 1 , 0x20 },
236
- {"ABCDEF0908070605040302010000000000000000000000000000000000000000" , 31 , 0xAB },
237
- {"ABCDEF0908070605040302010000000000000000000000000000000000000000" , 32 , 0x00 },
238
- {"ABCDEF0908070605040302010000000000000000000000000000000000000000" , 500 , 0x00 },
239
- }
240
- for _ , test := range tests {
241
- v := new (big.Int ).SetBytes (common .Hex2Bytes (test .x ))
242
- actual := bigEndianByteAt (v , test .y )
243
- if actual != test .exp {
244
- t .Fatalf ("Expected [%v] %v:th byte to be %v, was %v." , test .x , test .y , test .exp , actual )
245
- }
246
- }
247
- }
248
-
249
- func TestLittleEndianByteAt (t * testing.T ) {
250
- tests := []struct {
251
- x string
252
- y int
253
- exp byte
254
- }{
255
- {"00" , 0 , 0x00 },
256
- {"01" , 1 , 0x00 },
257
- {"00" , 1 , 0x00 },
258
- {"01" , 0 , 0x00 },
259
- {"0000000000000000000000000000000000000000000000000000000000102030" , 0 , 0x00 },
260
- {"0000000000000000000000000000000000000000000000000000000000102030" , 1 , 0x00 },
261
- {"ABCDEF0908070605040302010000000000000000000000000000000000000000" , 31 , 0x00 },
262
- {"ABCDEF0908070605040302010000000000000000000000000000000000000000" , 32 , 0x00 },
263
- {"ABCDEF0908070605040302010000000000000000000000000000000000000000" , 0 , 0xAB },
264
- {"ABCDEF0908070605040302010000000000000000000000000000000000000000" , 1 , 0xCD },
265
- {"00CDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" , 0 , 0x00 },
266
- {"00CDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff" , 1 , 0xCD },
267
- {"0000000000000000000000000000000000000000000000000000000000102030" , 31 , 0x30 },
268
- {"0000000000000000000000000000000000000000000000000000000000102030" , 30 , 0x20 },
269
- {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" , 32 , 0x0 },
270
- {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" , 31 , 0xFF },
271
- {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" , 0xFFFF , 0x0 },
272
- }
273
- for _ , test := range tests {
274
- v := new (big.Int ).SetBytes (common .Hex2Bytes (test .x ))
275
- actual := Byte (v , 32 , test .y )
276
- if actual != test .exp {
277
- t .Fatalf ("Expected [%v] %v:th byte to be %v, was %v." , test .x , test .y , test .exp , actual )
278
- }
279
- }
280
- }
0 commit comments