Sha256: a70dc7993907ef5c2a87cc8e8b9fdac15cb0144f4b9938570895b4dddea15d10

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

# Test for facets/comparable/bound.rb

require 'facets/comparable/bound.rb'

require 'test/unit'

class TestComparable < Test::Unit::TestCase

  def test_at_most
    assert_equal( 3, 3.at_most(4) )
    assert_equal( 4, 4.at_most(4) )
    assert_equal( 4, 5.at_most(4) )
  end

  def test_at_least
    assert_equal( 4, 3.at_least(4) )
    assert_equal( 4, 4.at_least(4) )
    assert_equal( 5, 5.at_least(4) )
  end

  def test_clip
    assert_equal( 4, 3.clip(4) )
    assert_equal( 4, 4.clip(4) )
    assert_equal( 5, 5.clip(4) )
    assert_equal( 4, 4.clip(3,5) )
    assert_equal( 3, 3.clip(3,5) )
    assert_equal( 5, 5.clip(3,5) )
    assert_equal( 3, 2.clip(3,5) )
    assert_equal( 5, 6.clip(3,5) )
    assert_equal( 'd', 'd'.clip('c','e') )
    assert_equal( 'c', 'c'.clip('c','e') )
    assert_equal( 'e', 'e'.clip('c','e') )
    assert_equal( 'c', 'b'.clip('c','e') )
    assert_equal( 'e', 'f'.clip('c','e') )
  end

  def test_cap
    assert_equal( 3, 3.cap(4) )
    assert_equal( 4, 4.cap(4) )
    assert_equal( 4, 5.cap(4) )
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.2.0 test/unit/comparable/test_bound.rb
facets-2.2.1 test/unit/comparable/test_bound.rb
facets-2.3.0 test/core/comparable/test_bound.rb