Sha256: ed6761e11809abdd4b390fdd64f3555d5bda88673941b0fc6eea685f2e4601b8

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'test/unit'

require 'rectify'

class TC_rectify < Test::Unit::TestCase

  def test_wrap_rectify
    assert(0.5.wrap_rectify(1) == 0.5)
    assert(5.5.wrap_rectify(1) =~ 0.5)
    assert(-7.25.wrap_rectify(2) =~ 0.75)
    assert(-7.25.wrap_rectify(2,0.5) =~ 1.75)
    assert(-7.25.wrap_rectify(0.5,2) =~ 1.75)
    assert(2.wrap_rectify(0.5,2) == 0.5)
    assert(0.5.wrap_rectify(0.5,2) == 0.5)
    assert(0.5.wrap_rectify(0,0) == 0)
  end
  
  def test_cut_rectify
    assert(0.5.cut_rectify(1) == 0.5)
    assert(5.5.cut_rectify(1) == 1)
    assert(-7.25.cut_rectify(2) == 0)
    assert(-7.25.cut_rectify(2,0.5) == 0.5)
    assert(-7.25.cut_rectify(0.5,2) == 0.5)
    assert(2.cut_rectify(0.5,2) == 2)
    assert(0.5.cut_rectify(0.5,2) == 0.5)
    assert(0.5.cut_rectify(0,0) == 0)
  end

  def test_at_most
    assert((-5..5).collect{|v| v.at_most(2)} ==
           [-5,-4,-3,-2,-1,0,1,2,2,2,2])
  end
  
  def test_at_least
    assert((-5..5).collect{|v| v.at_least(-1.5)} ==
           [-1.5,-1.5,-1.5,-1.5,-1,0,1,2,3,4,5])
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eymiha_math-0.1.1 test/tc_rectify.rb