Sha256: 409b8708e78edaa95ac49e6b2df84a4eeca1e1d3268a272c1d83bd89377c634c

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

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

require 'eymiha/units'

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

  def test_unit_identifiers
    
    Units.create :length do |m|
      m.system :english do |s|
        s.unit :name => :inch,
               :plural => :inches,
               :abbrev => :in
        s.unit :name => :foot,
               :plural => :feet,
               :abbrev => [ :ft ]
        s.unit :name => :yard,
               :abbrevs => :yd
      end
    end
    
    assert(Units.length.english.inch.kind_of?(UnitsUnit))
    assert(Units.length.english.inch.plural == 'inches')
    assert(Units.length.english.inch.abbrevs == [ 'in' ])
    assert(Units.length.english.foot.kind_of?(UnitsUnit))
    assert(Units.length.english.foot.plural == 'feet')
    assert(Units.length.english.foot.abbrevs == [ 'ft' ])
    assert(Units.length.english.yard.kind_of?(UnitsUnit))
    assert(Units.length.english.yard.plural == 'yards')
    assert(Units.length.english.yard.abbrevs == [ 'yd' ])

    assert_raise(UnitsException) {  Units.length.english.unit({}) }
    assert(Units.lookup('inch')[0] == Units.length.english.inch)
    assert(Units.lookup('inches')[0] == Units.length.english.inch)
    assert(Units.lookup('in')[0] == Units.length.english.inch)
    assert(Units.lookup('foot')[0] == Units.length.english.foot)
    assert(Units.lookup('feet')[0] == Units.length.english.foot)
    assert(Units.lookup('ft')[0] == Units.length.english.foot)
    assert(Units.lookup('yard')[0] == Units.length.english.yard)
    assert(Units.lookup('yards')[0] == Units.length.english.yard)
    assert(Units.lookup('yd')[0] == Units.length.english.yard)
 
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

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