Debian Codegraph @

ff/mul_test.go

raw symbols SCIP
1 package ff
2
3 import (
4 "math/big"
5 "reflect"
6 "testing"
7 )
8
9 func Test_mul(t *testing.T) {
10 type args struct {
11 x Element
12 y Element
13 }
14 tests := []struct {
15 name string
16 args args
17 wantZ Element
18 }{
19 {"1*1", args{Element{1, 0, 0, 0}, Element{1, 0, 0, 0}}, Element{1, 0, 0, 0}},
20 }
21 for _, tt := range tests {
22 t.Run(tt.name, func(t *testing.T) {
23 if gotZ := mul(tt.args.x, tt.args.y); !reflect.DeepEqual(gotZ, tt.wantZ) {
24 t.Errorf("mul() = %v, want %v", gotZ, tt.wantZ)
25 }
26 })
27 }
28 }
29
30 func Benchmark_mul(b *testing.B) {
31 x := randomElement(1)
32 y := randomElement(2)
33 b.ResetTimer()
34 for i := 0; i < b.N; i++ {
35 mul(x, y)
36 }
37 }
38
39 func Benchmark_mul_BI(b *testing.B) {
40 x := randomElement(1)
41 y := randomElement(2)
42 A, B := ElementToBigInt(x), ElementToBigInt(y)
43 C := new(big.Int)
44 b.ResetTimer()
45 for i := 0; i < b.N; i++ {
46 C.Mod(C.Mul(A, B), pBI)
47 }
48 }