summaryrefslogtreecommitdiffstats
path: root/test/openssl/test_random.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/openssl/test_random.rb')
-rw-r--r--test/openssl/test_random.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/openssl/test_random.rb b/test/openssl/test_random.rb
new file mode 100644
index 00000000..33af3757
--- /dev/null
+++ b/test/openssl/test_random.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+require_relative "utils"
+
+if defined?(OpenSSL)
+
+class OpenSSL::TestRandom < OpenSSL::TestCase
+ def test_random_bytes
+ assert_equal("", OpenSSL::Random.random_bytes(0))
+ assert_equal(12, OpenSSL::Random.random_bytes(12).bytesize)
+ end
+
+ def test_pseudo_bytes
+ # deprecated as of OpenSSL 1.1.0
+ assert_equal("", OpenSSL::Random.pseudo_bytes(0))
+ assert_equal(12, OpenSSL::Random.pseudo_bytes(12).bytesize)
+ end if OpenSSL::Random.methods.include?(:pseudo_bytes)
+end
+
+end