Sha256: 15cacd3e5859ca2b72a9f9042743f09f83fa2e2236538d86516332398ce09c64

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

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

require 'eymiha/units'

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

  def test_unit_ambiguity
    
    Units.create :volume do |m|
      m.system :english do |s|
        s.unit :name => :ounce, :abbrev => :oz
      end
    end
    volume_ounce = Units.volume.english.ounce
    Units.create :mass do |m|
      m.system :english do |s|
        s.unit :name => :ounce, :abbrev => :oz
      end
    end
    mass_ounce = Units.mass.english.ounce
    
    assert(volume_ounce.equals.unit == {volume_ounce => 1})
    assert(mass_ounce.equals.unit == {mass_ounce => 1})
    
    Units.create :volume do |m|
      m.system :english do |s|
        s.unit :name => :cup, :abbrev => :c, :equals => 16.ounces
      end
    end
    cup = Units.volume.english.cup
    assert(cup.equals.unit == {volume_ounce => 1})

    Units.create :mass do |m|
      m.system :english do |s|
        s.unit :name => :pound, :abbrev => :lb, :equals => 16.ounces
      end
    end
    pound = Units.mass.english.pound
    assert(pound.equals.unit == {mass_ounce => 1})
    
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

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