libgo: Merge from revision 18783:00cce3a34d7e of master library.
[official-gcc.git] / libgo / go / crypto / rand / util_test.go
blob33f9820371a7166522a67a25cbc5f2238d304dfd
1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package rand_test
7 import (
8 "crypto/rand"
9 "testing"
12 // http://golang.org/issue/6849.
13 func TestPrimeSmall(t *testing.T) {
14 for n := 2; n < 10; n++ {
15 p, err := rand.Prime(rand.Reader, n)
16 if err != nil {
17 t.Fatalf("Can't generate %d-bit prime: %v", n, err)
19 if p.BitLen() != n {
20 t.Fatalf("%v is not %d-bit", p, n)
22 if !p.ProbablyPrime(32) {
23 t.Fatalf("%v is not prime", p)