public
Created

How to use assert_in_delta

  • Download Gist
testing_assert_in_delta.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
require 'test/unit'
 
class TestAssertInDelta < Test::Unit::TestCase
def test_assert_in_delta
# Check that the calculated value is what we expect.
assert_in_delta(0.05, (5.0 / 100), 0.001)
# Check that the calculated value is still in range.
assert_in_delta(0.05, (5.1 / 100), 0.001)
# Great for testing the results of calculations.
assert_in_delta(33.333, ((9000 * 100.00) / (300 * 90.00)), 0.001)
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.