Sha256: b9a66496b303eb60bfa075c599c3b2441d75b20b2faad52686f8ea397f698861

Contents?: true

Size: 860 Bytes

Versions: 2

Compression:

Stored size: 860 Bytes

Contents

require 'test/unit'
require 'test/framework'
require 'eymiha/units'

class TC_unit_arithmetic < Test::Unit::TestCase
  
  include UnitsTest

  def test_unit_arithmetic

    Units.create :length do |m|
      m.system :english do |s|
        s.unit :name => :inch,
               :plural => :inches,
               :abbrev => :in
      end
    end
    
    inch = Units.length.english.inch.equals
    assert(inch.to_s == "1 inch")
    assert(inch == 1.inch)
    
    yard = inch*36
    assert(yard.to_s == "36 inches")
    assert(yard == 36.in)

    foot = yard/3
    assert(foot.to_s == "12 inches")
    assert(foot == 12.in)
    
    half_foot = foot-6
    assert(half_foot.to_s == "6 inches")
    assert(half_foot == 6.in)
    
    yard_and_a_half = yard+18
    assert(yard_and_a_half.to_s == "54 inches")
    assert(yard_and_a_half == 54.in)

  end
    
end

Version data entries

2 entries across 2 versions & 1 rubygems

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