PageRenderTime 62ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/core/range/test_within.rb

https://bitbucket.org/mediashelf/fedora-migrator
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
  1. require 'facets/range/within'
  2. require 'test/unit'
  3. class TestRangeWithin < Test::Unit::TestCase
  4. def test_within?
  5. assert( (4..5).within?(3..6) )
  6. assert( (3..6).within?(3..6) )
  7. assert(! (2..5).within?(3..6) )
  8. assert(! (5..7).within?(3..6) )
  9. end
  10. def test_umbrella_aligned
  11. assert_equal( [0,0], (3..6).umbrella(3..6) )
  12. assert_equal( [0,0], (3...6).umbrella(3...6) )
  13. end
  14. def test_umbrella_partial_aligned
  15. assert_equal( [1,0], (3..6).umbrella(2..6) )
  16. assert_equal( [0,1], (3..6).umbrella(3..7) )
  17. assert_equal( [-1,0], (3..6).umbrella(4..6) )
  18. assert_equal( [0,-1], (3..6).umbrella(3..5) )
  19. end
  20. def test_umbrella_offset
  21. assert_equal( [1,1], (3..6).umbrella(2..7) )
  22. assert_equal( [-1,1], (3..6).umbrella(4..7) )
  23. assert_equal( [1,-1], (3..6).umbrella(2..5) )
  24. assert_equal( [-1,-1], (3..6).umbrella(4..5) )
  25. end
  26. def test_umbrella_offset_by_exclusion
  27. assert_equal( [0,1], (10...20).umbrella(10..20) )
  28. end
  29. end