diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-10 05:57:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-10 05:57:11 +0000 |
commit | b402cc71616169bab03fb856e73a7d6519330ca3 (patch) | |
tree | dadead0ea1a5a4b8e5febef318f9b1b3e60f77c8 /test/test_securerandom.rb | |
parent | 518713fd651c8d53a6493a354eadb41361c18029 (diff) |
random.c: use bytes
* random.c (obj_random_bytes): base on bytes method instead of
rand method, not to call toplevel rand method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_securerandom.rb')
-rw-r--r-- | test/test_securerandom.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_securerandom.rb b/test/test_securerandom.rb index 515d05e6b2..cd5cb1dee2 100644 --- a/test/test_securerandom.rb +++ b/test/test_securerandom.rb @@ -157,6 +157,20 @@ end end end + def test_s_random_number_not_default + msg = "SecureRandom#random_number should not be affected by srand" + seed = srand(0) + x = @it.random_number(1000) + 10.times do|i| + srand(0) + return unless @it.random_number(1000) == x + end + srand(0) + assert_not_equal(x, @it.random_number(1000), msg) + ensure + srand(seed) if seed + end + def test_uuid uuid = @it.uuid assert_equal(36, uuid.size) |