Skip to content

Instantly share code, notes, and snippets.

@litonico
Created July 15, 2015 03:45
Show Gist options
  • Save litonico/16c46ea29c675f00a2ce to your computer and use it in GitHub Desktop.
Save litonico/16c46ea29c675f00a2ce to your computer and use it in GitHub Desktop.
Ruby lacks exclusive between
require 'minitest/autorun'
class TestExclusiveBetween < Minitest::Test
def assert_between min, max, value
# Fill in here
end
def refute_between min, max, value
# Fill in here
end
def test_number_between_min_and_max
assert_between 0.0, 1.0, 0.4
end
def test_maximum_is_included
assert_between 0.0, 1.0, 1.0
end
def test_just_a_little_above_minimum_is_included
assert_between 0.0, 1.0, Float::EPSILON
end
def test_minimum_is_excluded
refute_between 0.0, 1.0, 0.0
end
def test_above_max_is_excluded
refute_between 0.0, 1.0, 2.0
end
def test_just_a_little_above_maximum_is_excluded
refute_between 0.0, 1.0, 1.0+Float::EPSILON
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment