/vendor/gems/facets-2.4.5/test/core/range/test_within.rb
Ruby | 36 lines | 29 code | 7 blank | 0 comment | 0 complexity | 9863d40b200c96d64603e440c4328c70 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
- require 'facets/range/within'
- require 'test/unit'
- class TestRangeWithin < Test::Unit::TestCase
- def test_within?
- assert( (4..5).within?(3..6) )
- assert( (3..6).within?(3..6) )
- assert(! (2..5).within?(3..6) )
- assert(! (5..7).within?(3..6) )
- end
- def test_umbrella_aligned
- assert_equal( [0,0], (3..6).umbrella(3..6) )
- assert_equal( [0,0], (3...6).umbrella(3...6) )
- end
- def test_umbrella_partial_aligned
- assert_equal( [1,0], (3..6).umbrella(2..6) )
- assert_equal( [0,1], (3..6).umbrella(3..7) )
- assert_equal( [-1,0], (3..6).umbrella(4..6) )
- assert_equal( [0,-1], (3..6).umbrella(3..5) )
- end
- def test_umbrella_offset
- assert_equal( [1,1], (3..6).umbrella(2..7) )
- assert_equal( [-1,1], (3..6).umbrella(4..7) )
- assert_equal( [1,-1], (3..6).umbrella(2..5) )
- assert_equal( [-1,-1], (3..6).umbrella(4..5) )
- end
- def test_umbrella_offset_by_exclusion
- assert_equal( [0,1], (10...20).umbrella(10..20) )
- end
- end