require 'test/unit' require 'test/framework' require 'eymiha/units' class TC_measure_create < Test::Unit::TestCase include UnitsTest def test_measure_create assert(Units.units_measures == []) assert(Units.create(:length).kind_of?(UnitsMeasure)) assert(Units.length.kind_of?(UnitsMeasure)) assert_raise(UnitsException) { Units.time } assert(Units.units_measures.index('length') != nil) assert(Units.units_measures.index('time') == nil) assert(Units.units_measures.index('distance') == nil) assert(Units.create('time').kind_of?(UnitsMeasure)) assert(Units.size == 2) assert(Units.time.kind_of?(UnitsMeasure)) assert(Units.units_measures.index('length') != nil) assert(Units.units_measures.index('time') != nil) assert(Units.units_measures.index('distance') == nil) assert(Units.derive(:distance, 'length').kind_of?(UnitsMeasure)) assert(Units.size == 3) assert(Units.distance.kind_of?(UnitsMeasure)) assert(Units.length == Units.distance) assert(Units.units_measures.index('length') != nil) assert(Units.units_measures.index('time') != nil) assert(Units.units_measures.index('distance') != nil) assert(Units.delete(:time).kind_of?(UnitsMeasure)) assert(Units.delete('time') == nil) assert(Units.delete('length').kind_of?(UnitsMeasure)) assert(Units.delete(:length) == nil) assert(Units.size == 1) assert_raise(UnitsException) { Units.time } assert_raise(UnitsException) { Units.length } assert(Units.units_measures.index('length') == nil) assert(Units.units_measures.index('time') == nil) assert(Units.units_measures.index('distance') != nil) assert(Units.clear == Units) assert(Units.size == 0) assert_raise(UnitsException) { Units.time } assert_raise(UnitsException) { Units.length } assert_raise(UnitsException) { Units.distance } assert(Units.units_measures.index('length') == nil) assert(Units.units_measures.index('time') == nil) assert(Units.units_measures.index('distance') == nil) assert(Units.units_measures == []) end end