MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / TestLittleEndianByteAt

Function TestLittleEndianByteAt

utils/big_test.go:239–272  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

237 }
238}
239func TestLittleEndianByteAt(t *testing.T) {
240 tests := []struct {
241 x string
242 y int
243 exp byte
244 }{
245 {"00", 0, 0x00},
246 {"01", 1, 0x00},
247 {"00", 1, 0x00},
248 {"01", 0, 0x00},
249 {"0000000000000000000000000000000000000000000000000000000000102030", 0, 0x00},
250 {"0000000000000000000000000000000000000000000000000000000000102030", 1, 0x00},
251 {"ABCDEF0908070605040302010000000000000000000000000000000000000000", 31, 0x00},
252 {"ABCDEF0908070605040302010000000000000000000000000000000000000000", 32, 0x00},
253 {"ABCDEF0908070605040302010000000000000000000000000000000000000000", 0, 0xAB},
254 {"ABCDEF0908070605040302010000000000000000000000000000000000000000", 1, 0xCD},
255 {"00CDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff", 0, 0x00},
256 {"00CDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff", 1, 0xCD},
257 {"0000000000000000000000000000000000000000000000000000000000102030", 31, 0x30},
258 {"0000000000000000000000000000000000000000000000000000000000102030", 30, 0x20},
259 {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 32, 0x0},
260 {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 31, 0xFF},
261 {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0xFFFF, 0x0},
262 }
263 for _, test := range tests {
264 b, _ := hex.DecodeString(test.x)
265 v := new(big.Int).SetBytes(b)
266 actual := Byte(v, 32, test.y)
267 if actual != test.exp {
268 t.Fatalf("expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
269 }
270
271 }
272}
273
274func TestS256(t *testing.T) {
275 tests := []struct{ x, y *big.Int }{

Callers

nothing calls this directly

Calls 3

ByteFunction · 0.85
SetBytesMethod · 0.80
FatalfMethod · 0.80

Tested by

no test coverage detected