MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestBigEndianByteAt

Function TestBigEndianByteAt

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

Source from the content-addressed store, hash-verified

211}
212
213func TestBigEndianByteAt(t *testing.T) {
214 tests := []struct {
215 x string
216 y int
217 exp byte
218 }{
219 {"00", 0, 0x00},
220 {"01", 1, 0x00},
221 {"00", 1, 0x00},
222 {"01", 0, 0x01},
223 {"0000000000000000000000000000000000000000000000000000000000102030", 0, 0x30},
224 {"0000000000000000000000000000000000000000000000000000000000102030", 1, 0x20},
225 {"ABCDEF0908070605040302010000000000000000000000000000000000000000", 31, 0xAB},
226 {"ABCDEF0908070605040302010000000000000000000000000000000000000000", 32, 0x00},
227 {"ABCDEF0908070605040302010000000000000000000000000000000000000000", 500, 0x00},
228 }
229 for _, test := range tests {
230 b, _ := hex.DecodeString(test.x)
231 v := new(big.Int).SetBytes(b)
232 actual := bigEndianByteAt(v, test.y)
233 if actual != test.exp {
234 t.Fatalf("expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
235 }
236
237 }
238}
239func TestLittleEndianByteAt(t *testing.T) {
240 tests := []struct {
241 x string

Callers

nothing calls this directly

Calls 3

bigEndianByteAtFunction · 0.85
SetBytesMethod · 0.80
FatalfMethod · 0.80

Tested by

no test coverage detected