File: search_test.go

package info (click to toggle)
golang-github-tscholl2-siec 0.0~git20210707.9bdfc48-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 360 kB
  • sloc: makefile: 3
file content (46 lines) | stat: -rw-r--r-- 963 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
39
40
41
42
43
44
45
46
package main

import (
	"math/big"
	"reflect"
	"testing"
)

func BenchmarkNextSiec(b *testing.B) {
	M := new(big.Int)
	M.SetString("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 16)
	b.ResetTimer()
	for i := 1; i < b.N; i++ {
		nextSiec(M)
	}
}

func Test_nextSiec(t *testing.T) {
	type args struct {
		M *big.Int
	}
	tests := []struct {
		name  string
		args  args
		wantT *big.Int
		wantQ *big.Int
	}{
		{
			name:  "10^10",
			args:  args{M: big.NewInt(10000000000)},
			wantT: big.NewInt(200001),
			wantQ: big.NewInt(10000100003),
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			gotT, gotQ := nextSiec(tt.args.M)
			if !reflect.DeepEqual(gotT, tt.wantT) {
				t.Errorf("nextSiec() gotT = %v, want %v", gotT, tt.wantT)
			}
			if !reflect.DeepEqual(gotQ, tt.wantQ) {
				t.Errorf("nextSiec() gotQ = %v, want %v", gotQ, tt.wantQ)
			}
		})
	}
}