Skip to content
Create a gist now

Instantly share code, notes, and snippets.

How to use assert_in_delta
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.