require 'test/unit' require 'test/framework' require 'units' class TC_unit_identifiers < Test::Unit::TestCase understands 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