diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-20 09:26:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-20 09:26:38 +0000 |
commit | 1cd9c3ce62aef3c45e72c002cbc17706ffca67c9 (patch) | |
tree | a9f478ef02c3292615b9267bd36cd168a3a81418 /test | |
parent | 74bf1767e3e0812c3f526a3bb0972e9145ed4461 (diff) |
random.c: Random.bytes
* random.c (random_s_bytes): new method Random.bytes, which is
equivalent to Random::DEFAULT.bytes. [Feature #4938]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_rand.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test/ruby/test_rand.rb b/test/ruby/test_rand.rb index 882d33fb40..136ee4f912 100644 --- a/test/ruby/test_rand.rb +++ b/test/ruby/test_rand.rb @@ -347,10 +347,15 @@ END end def assert_random_bytes(r) + srand(0) assert_equal("", r.bytes(0)) - assert_equal("\xAC".force_encoding("ASCII-8BIT"), r.bytes(1)) - assert_equal("/\xAA\xC4\x97u\xA6\x16\xB7\xC0\xCC".force_encoding("ASCII-8BIT"), - r.bytes(10)) + assert_equal("", Random.bytes(0)) + x = "\xAC".force_encoding("ASCII-8BIT") + assert_equal(x, r.bytes(1)) + assert_equal(x, Random.bytes(1)) + x = "/\xAA\xC4\x97u\xA6\x16\xB7\xC0\xCC".force_encoding("ASCII-8BIT") + assert_equal(x, r.bytes(10)) + assert_equal(x, Random.bytes(10)) end def test_random_range |