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

Function TestPaddedBigBytes

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

Source from the content-addressed store, hash-verified

116}
117
118func TestPaddedBigBytes(t *testing.T) {
119 tests := []struct {
120 num *big.Int
121 n int
122 result []byte
123 }{
124 {num: big.NewInt(0), n: 4, result: []byte{0, 0, 0, 0}},
125 {num: big.NewInt(1), n: 4, result: []byte{0, 0, 0, 1}},
126 {num: big.NewInt(512), n: 4, result: []byte{0, 0, 2, 0}},
127 {num: BigPow(2, 32), n: 4, result: []byte{1, 0, 0, 0, 0}},
128 }
129 for _, test := range tests {
130 if result := PaddedBigBytes(test.num, test.n); !bytes.Equal(result, test.result) {
131 t.Errorf("PaddedBigBytes(%d, %d) = %v, want %v", test.num, test.n, result, test.result)
132 }
133 }
134}
135
136func BenchmarkPaddedBigBytesLargePadding(b *testing.B) {
137 bigint := MustParseBig256("123456789123456789123456789123456789")

Callers

nothing calls this directly

Calls 3

BigPowFunction · 0.85
PaddedBigBytesFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected