예제 #1
0
func TestDoubleFactorial(t *testing.T) {
	d := new(big.Int)
	answer := new(big.Int)
	for _, tc := range tcs {
		if _, ok := answer.SetString(tc.s, 10); !ok {
			t.Error("invalid test case", tc)
			continue
		}
		switch _ = double.DoubleFactorial(d, tc.n); {
		case d == nil:
			t.Error("nil result. test case", tc)
		case d.Cmp(answer) != 0:
			t.Log("wrong answer, test case", tc)
			t.Error("got", answer)
		}
	}
}
예제 #2
0
func BenchmarkDouble1e5(b *testing.B) {
	var z big.Int
	for i := 0; i < b.N; i++ {
		double.DoubleFactorial(&z, 1e5)
	}
}