Sha256: 6cbc5030354760d44977d4cf556b24751b51b37f7ebd21b4e657b5d32bd6d218

Contents?: true

Size: 980 Bytes

Versions: 16

Compression:

Stored size: 980 Bytes

Contents

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
facets-2.8.4 test/core/range/test_within.rb
facets-2.8.3 test/core/range/test_within.rb
facets-2.8.2 test/core/range/test_within.rb
facets-2.8.1 test/core/range/test_within.rb
facets-2.8.0 test/core/range/test_within.rb
facets-2.7.0 test/core/range/test_within.rb
facets-2.6.0 test/core/range/test_within.rb
facets-2.4.0 test/range/test_within.rb
facets-2.4.1 test/range/test_within.rb
facets-2.4.3 test/core/range/test_within.rb
facets-2.4.2 test/core/range/test_within.rb
facets-2.4.4 test/core/range/test_within.rb
facets-2.4.5 test/core/range/test_within.rb
facets-2.5.0 test/core/range/test_within.rb
facets-2.5.1 test/core/range/test_within.rb
facets-2.5.2 test/core/range/test_within.rb