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