Sha256: 93dfbc67aee0644a7d3d1ea94c064378b446567fbde5a586a9c8a6339eea9b83

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require 'test/unit'
require 'test/framework'

require 'eymiha/units'

class TC_measure_derive < Test::Unit::TestCase

  include UnitsTest
  
  def test_measure_derive
    
    assert((length = Units.create :length) == Units.length)
    assert(length.derived == nil)
    
    assert((distance = Units.derive 'distance', length) == Units.length)
    assert(distance.derived == nil)
    
    assert((area = Units.derive 'area', length**2) == Units.area)
    assert(area.derived.size == 1)
    assert(area.derived[Units.length] == 2)
    
    assert((volume = Units.derive 'volume', area*length) == Units.volume)
    assert(volume.derived.size == 1)
    assert(volume.derived[Units.length] == 3)
    
    assert((time = Units.create 'time') == Units.time)
    assert(time.derived == nil)
    
    assert((velocity = Units.derive :velocity, distance/time) ==
             Units.velocity)
    assert(velocity.derived.size == 2)
    assert(velocity.derived[Units.distance] == 1)
    assert(velocity.derived[Units.time] == -1)
    
    assert((acceleration = Units.derive :acceleration, distance/time**2) ==
             Units.acceleration)
    assert(acceleration.derived.size == 2)
    assert(acceleration.derived[Units.distance] == 1)
    assert(acceleration.derived[Units.time] == -2)
    
    assert(acceleration == Units.derive(:acceleration2, distance/time**2))
    assert(Units.acceleration2 == Units.acceleration)
    
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eymiha_units-1.0.1 test/tc_measure_derive.rb
eymiha_units-1.0.0 test/tc_measure_derive.rb