-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathu256_test.go
More file actions
43 lines (39 loc) · 726 Bytes
/
Copy pathu256_test.go
File metadata and controls
43 lines (39 loc) · 726 Bytes
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
package udecimal
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func TestBitlen(t *testing.T) {
testcases := []struct {
u u256
want int
}{
{
u: u256{hi: 0, lo: 0, carry: u128{hi: 0, lo: 0}},
want: 0,
},
{
u: u256{hi: 0, lo: 1, carry: u128{hi: 0, lo: 0}},
want: 1,
},
{
u: u256{hi: 0, lo: 0, carry: u128{hi: 0, lo: 1}},
want: 129,
},
{
u: u256{hi: 0, lo: 1, carry: u128{hi: 0, lo: 1}},
want: 129,
},
{
u: u256{hi: 0, lo: 1, carry: u128{hi: 123456789, lo: 1}},
want: 219,
},
}
for i, tc := range testcases {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
got := tc.u.bitLen()
require.Equal(t, tc.want, got)
})
}
}