File: normalize_test.go

package info (click to toggle)
golang-github-tscholl2-siec 0.0~git20210707.9bdfc48-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 360 kB
  • sloc: makefile: 3
file content (38 lines) | stat: -rw-r--r-- 871 bytes parent folder | download
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
package ff

import (
	"reflect"
	"testing"
)

func Test_normalize(t *testing.T) {
	type args struct {
		a Element
	}
	tests := []struct {
		name string
		args args
		want Element
	}{
		{"1", args{Element{1, 0, 0, 0}}, Element{1, 0, 0, 0}},
		{"0", args{Element{0, 0, 0, 0}}, Element{0, 0, 0, 0}},
		{"p", args{p}, Element{0, 0, 0, 0}},
		{"2p", args{Element{0x8008206104082, 0, 0x4002081, 0x8000000000000000}}, Element{0, 0, 0, 0}},
		{"2p+1", args{Element{0x8008206104083, 0, 0x4002081, 0x8000000000000000}}, Element{1, 0, 0, 0}},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := normalize(tt.args.a); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("normalize() = %v, want %v", got, tt.want)
			}
		})
	}
}

func Benchmark_normalize(b *testing.B) {
	a := randomElement(1)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		normalize(a)
	}
}