-
Notifications
You must be signed in to change notification settings - Fork 0
/
int_test.go
82 lines (68 loc) · 1.99 KB
/
int_test.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package elliptic2
import (
"testing"
"github.com/RyuaNerin/elliptic2/internal"
)
func Test_bifint_Add(t *testing.T) {
for idx, tc := range testCases_bfi {
r := newBFI().Add(tc.arg1, tc.arg2)
if r.Cmp(tc.add) != 0 {
t.Errorf("%d: invaild result", idx)
}
}
}
func Test_bifint_Mul(t *testing.T) {
for idx, tc := range testCases_bfi {
r := newBFI().Mul(tc.arg1, tc.arg2)
if r.Cmp(tc.mul) != 0 {
t.Errorf("%d: invaild result", idx)
}
}
}
func Test_bifint_Mod(t *testing.T) {
for idx, tc := range testCases_bfi {
r := newBFI().Mod(tc.arg1, tc.arg2)
if r.Cmp(tc.mod) != 0 {
t.Errorf("%d: invaild result", idx)
}
}
}
func Test_bifint_Div(t *testing.T) {
for idx, tc := range testCases_bfi {
r := newBFI().Div(tc.arg1, tc.arg2)
if r.Cmp(tc.div) != 0 {
t.Errorf("%d: invaild result", idx)
}
}
}
func Test_bifint_DivMod(t *testing.T) {
for idx, tc := range testCases_bfi {
r := newBFI().DivMod(tc.arg1, tc.arg2, tc.arg3)
if r.Cmp(tc.divMod) != 0 {
t.Errorf("%d: invaild result", idx)
}
}
}
var (
testCases_bfi = []struct {
arg1 *bfi
arg2 *bfi
arg3 *bfi
add *bfi
mul *bfi
mod *bfi
div *bfi
divMod *bfi
}{
{
arg1: wrapBFI(internal.HI(`4cffb0777d6dab9b28ac2dc6514ca8abbb3639fcbd910e2f2de0b25fef6b`)),
arg2: wrapBFI(internal.HI(`00fac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b`)),
arg3: wrapBFI(internal.HI(`01006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052`)),
add: wrapBFI(internal.HI(`4c0579a8b6c12888938d1437ea39f744de8a00e336a7f6d7c693c3a2bae0`)),
mul: wrapBFI(internal.HI(`3ad962c3abc20228801343ee994f6072ce29f57907db5f5e7258a9e54dad04c756838ed63490f7a712a75e08a82a703d2ee98616fe01e768994865`)),
mod: wrapBFI(internal.HI(`7f7c4331685480794c0f9f3a9405d9345b593cd30a3b1614c05d884510`)),
div: wrapBFI(internal.HI(`d1`)),
divMod: wrapBFI(internal.HI(`0x33fe52b13455aaa277153de8131aae871e7566ac4ede57bce25765c11d7b45f573e8a2051b2b8917349954a6c51886c2b611ab0db1896e1a87291d`)),
},
}
)