aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/crypto/rand/util_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/crypto/rand/util_test.go')
-rw-r--r--libgo/go/crypto/rand/util_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/libgo/go/crypto/rand/util_test.go b/libgo/go/crypto/rand/util_test.go
new file mode 100644
index 00000000000..33f9820371a
--- /dev/null
+++ b/libgo/go/crypto/rand/util_test.go
@@ -0,0 +1,26 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package rand_test
+
+import (
+ "crypto/rand"
+ "testing"
+)
+
+// http://golang.org/issue/6849.
+func TestPrimeSmall(t *testing.T) {
+ for n := 2; n < 10; n++ {
+ p, err := rand.Prime(rand.Reader, n)
+ if err != nil {
+ t.Fatalf("Can't generate %d-bit prime: %v", n, err)
+ }
+ if p.BitLen() != n {
+ t.Fatalf("%v is not %d-bit", p, n)
+ }
+ if !p.ProbablyPrime(32) {
+ t.Fatalf("%v is not prime", p)
+ }
+ }
+}