Sha256: 7c69bb0561fb6cf0a64ce498250eba4dd92d8147b63b44dc2859e172216a2a12

Contents?: true

Size: 677 Bytes

Versions: 23

Compression:

Stored size: 677 Bytes

Contents

require "spec_helper"

describe Stellar::Price, "#from_f" do
  subject{ Stellar::Price }
  let(:seed){ 225571644875421139403973254661022579608 } #generated using Random.new
  let(:random){ Random.new(seed) } 
  let(:iterations){ ENV["SMOKE_ITERATIONS"].present? ? ENV["SMOKE_ITERATIONS"].to_i : 2000}

  it "withstands a random smoke test" do
    iterations.times do |i|
      expected = random.rand
      actual_p = subject.from_f(expected)
      actual = actual_p.to_f

      expect(actual).to be_within(0.000000001).of(actual)
      expect(actual_p.n).to be <= Stellar::Price::MAX_PRECISION
      expect(actual_p.d).to be <= Stellar::Price::MAX_PRECISION
    end
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
stellar-base-0.1.4 spec/lib/stellar/price_spec.rb
stellar-base-0.1.3 spec/lib/stellar/price_spec.rb
stellar-base-0.1.2 spec/lib/stellar/price_spec.rb
stellar-base-0.1.1 spec/lib/stellar/price_spec.rb
stellar-base-0.1.0 spec/lib/stellar/price_spec.rb
stellar-base-0.0.20 spec/lib/stellar/price_spec.rb
stellar-base-0.0.19 spec/lib/stellar/price_spec.rb
stellar-base-0.0.18 spec/lib/stellar/price_spec.rb
stellar-base-0.0.17 spec/lib/stellar/price_spec.rb
stellar-base-0.0.16 spec/lib/stellar/price_spec.rb
stellar-base-0.0.15 spec/lib/stellar/price_spec.rb
stellar-base-0.0.14 spec/lib/stellar/price_spec.rb
stellar-base-0.0.13 spec/lib/stellar/price_spec.rb
stellar-base-0.0.12 spec/lib/stellar/price_spec.rb
stellar-base-0.0.11 spec/lib/stellar/price_spec.rb
stellar-base-0.0.10 spec/lib/stellar/price_spec.rb
stellar-base-0.0.9 spec/lib/stellar/price_spec.rb
stellar-base-0.0.8 spec/lib/stellar/price_spec.rb
stellar-base-0.0.7 spec/lib/stellar/price_spec.rb
stellar-base-0.0.6 spec/lib/stellar/price_spec.rb