File: utility_spec.rb

package info (click to toggle)
ruby-uuidtools 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 200 kB
  • sloc: ruby: 1,233; makefile: 16
file content (21 lines) | stat: -rw-r--r-- 651 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require File.expand_path("../../spec_helper.rb", __FILE__)

describe SecureRandom do
  it "should correctly obtain random bits" do
    bits = []
    1000.times do
      bits << SecureRandom.random_bytes(16)
    end
    # Check to make sure that none of the 10,000 strings were duplicates
    expect((bits.map {|x| x.to_s}).uniq.size).to eql(bits.size)
  end

  it "should return the correct number of random bits" do
    expect(SecureRandom.random_bytes(16).size).to eql(16)
    expect(SecureRandom.random_bytes(6).size).to eql(6)
  end

  it "should return a sane random number" do
    expect(SecureRandom.random_number(5000)).to be < 5000
  end
end