Sha256: 89b5781bbe53b5b864a71f6ed0f45574b8d8dcc174662cd890e80f8a189ce9c9

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

require 'test/unit'

require 'facet/range/to_r'
require 'facet/range/to_range'
require 'facet/range/umbrella'
require 'facet/range/within%3F'


class TC_Range < Test::Unit::TestCase

  # to_r
  
  def test_to_r
    a = (0..10)
    assert_equal( a, a.to_r )
  end
  
  def test_to_range
    a = (0..10)
    assert_equal( a, a.to_range )
  end
  
  # umbrella
  
  def test_umbrella
    assert_equal( [1,1], (3..6).umbrella(2..7) )
    assert_equal( [0,1], (3..6).umbrella(3..7) )
    assert_equal( [-1,1], (3..6).umbrella(4..7) )
    assert_equal( [1,0], (3..6).umbrella(2..6) )
    assert_equal( [0,0], (3..6).umbrella(3..6) )
    assert_equal( [-1,0], (3..6).umbrella(4..6) )
    assert_equal( [1,-1], (3..6).umbrella(2..5) )
    assert_equal( [0,-1], (3..6).umbrella(3..5) )
    assert_equal( [-1,-1], (3..6).umbrella(4..5) )
  end
  
  # within?
  
  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
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 test/range/tc_range.rb
facets-0.7.1 test/range/tc_range.rb
facets-0.7.2 test/range/tc_range.rb