Changeset 256


Ignore:
Timestamp:
Sep 11, 2009, 1:10:23 AM (11 years ago)
Author:
KOBAYASHI, Shinji
Message:

assumed_library_types move test/unit to rspec

Location:
ruby/branches/0.5
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • ruby/branches/0.5/lib/open_ehr/assumed_library_types.rb

    r255 r256  
    8181    end # end of Interval
    8282 
    83     class TIME_DEFINITIONS < Any
     83    class TimeDefinitions < Any
    8484      DAYS_IN_LEAP_YEAR = 366
    8585      DAYS_IN_WEEK = 7
     
    120120        mo >= 1 and mo <= MONTH_IN_YEAR
    121121      end
    122     end # end of TIME_DEFINITIONS
    123 
    124     module ISO8601_DATE_MODULE
     122    end # end of TimeDefinitions
     123
     124    module ISO8601DateModule
    125125      attr_reader :year, :month, :day
     126
    126127      def year=(year)
    127         raise ArgumentError, "Year is not valid" unless ISO8601_DATE.valid_year?(year)
     128        unless !year.nil? && ISO8601Date.valid_year?(year)
     129          raise ArgumentError, "Year is not valid"
     130        end
    128131        @year = year
    129132      end
     133
    130134      def month=(month)
    131         raise ArgumentError, "Month is not valid" unless month.nil? or ISO8601_DATE.valid_month?(month)
     135        raise ArgumentError, "Month is not valid" unless month.nil? or ISO8601Date.valid_month?(month)
    132136        @month = month
    133137      end
    134138
    135139      def day=(day)
    136         raise ArgumentError, "Day is not valid" unless day.nil? or ISO8601_DATE.valid_day?(@year, @month, day)
     140        raise ArgumentError, "Day is not valid" unless day.nil? or ISO8601Date.valid_day?(@year, @month, day)
    137141        @day = day
    138142      end
     
    174178    end
    175179
    176     class ISO8601_DATE < TIME_DEFINITIONS
    177       include ISO8601_DATE_MODULE
     180    class ISO8601Date < TimeDefinitions
     181      include ISO8601DateModule
    178182      def initialize(string)
    179183        /(\d{4})(?:-(\d{2})(?:-(\d{2})?)?)?/ =~ string
     
    205209    end # end of ISO8601_DATE
    206210
    207     module ISO8601_TIME_MODULE
     211    module ISO8601TimeModule
    208212      attr_reader :hour, :minute, :second, :fractional_second, :timezone
    209213
     
    289293    end
    290294
    291     class ISO8601_TIME < TIME_DEFINITIONS
    292       include ISO8601_TIME_MODULE
     295    class ISO8601Time < TimeDefinitions
     296      include ISO8601TimeModule
    293297      def initialize(string)
    294298        /(\d{2}):?(\d{2})?(:?)(\d{2})?((\.|,)(\d+))?(Z|([+-](\d{2}):?(\d{2})))?/ =~ string
     
    361365    end # end of ISO8601_TIME
    362366
    363     module ISO8601_DATE_TIME_MODULE
    364       include ISO8601_DATE_MODULE, ISO8601_TIME_MODULE
     367    module ISO8601DateTimeModule
     368      include ISO8601DateModule, ISO8601TimeModule
    365369      def as_string
    366370        if (!@year.nil? and !@month.nil? and !@day.nil?)
     
    390394    end
    391395
    392     class ISO8601_DATE_TIME < ISO8601_DATE
    393       include ISO8601_DATE_TIME_MODULE
     396    class ISO8601DateTime < ISO8601Date
     397      include ISO8601DateTimeModule
    394398      def initialize(string)
    395399        /(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|([+-]\d{2}):?(\d{2}))?)?)?)?/ =~ string
     
    544548      end
    545549    end
    546     class ISO8601_DURATION < TIME_DEFINITIONS
     550    class ISO8601_DURATION < TimeDefinitions
    547551      include ISO8601_DURATION_MODULE
    548552      def initialize(str)
  • ruby/branches/0.5/spec/lib/open_ehr/assumed_library_types/interval_spec.rb

    r255 r256  
     1<<<<<<< .mine
    12require File.dirname(__FILE__) + '/../../../spec_helper'
    23include OpenEHR::AssumedLibraryTypes
     
    4849  end
    4950
    50   it 'should have not have 1' do
     51  it 'should not have 1' do
    5152    @interval.has?(1).should_not be_true
    5253  end
     
    138139  end
    139140end
     141=======
     142require File.dirname(__FILE__) + '/../../../spec_helper'
     143include OpenEHR::AssumedLibraryTypes
     144
     145describe Interval do
     146  before(:each) do
     147    @interval = Interval.new(:upper => 10,
     148                             :lower => 1)
     149  end
     150
     151  it 'should be an instance of Interval' do
     152    @interval.should be_an_instance_of Interval
     153  end
     154
     155  it 's upper should be greater than lower' do
     156    @interval.upper.should be > @interval.lower
     157  end
     158
     159  it 's upper should be equal 10' do
     160    @interval.upper.should == 10
     161  end
     162
     163  it 's lower should be equal 1' do
     164    @interval.lower.should == 1
     165  end
     166
     167  it 'should raise ArgumentError with smaller upper' do
     168    lambda {@interval.upper = -1}.should raise_error ArgumentError
     169  end
     170
     171  it 'should raise ArgumentError with greater lower' do
     172    lambda {@interval.lower = 11}.should raise_error ArgumentError
     173  end
     174
     175  it 'should have 5' do
     176    @interval.has?(5).should be_true
     177  end
     178
     179  it 'should not have 11' do
     180    @interval.has?(11).should_not be_true
     181  end
     182
     183  it 'should not have -1' do
     184    @interval.has?(-1).should_not be_true
     185  end
     186
     187  it 'should not have 10' do
     188    @interval.has?(10).should_not be_true
     189  end
     190
     191  it 'should have not have 1' do
     192    @interval.has?(1).should_not be_true
     193  end
     194
     195  describe Interval, 'when lower included' do
     196    before do
     197      @interval.lower_included = true
     198    end
     199
     200    it 'should be lower_included' do
     201      @interval.should be_lower_included
     202    end
     203
     204    it 'should have 1 when lower included' do
     205      @interval.has?(1).should be_true
     206    end
     207
     208    after do
     209      @interval.lower_included = false
     210    end
     211  end
     212
     213  describe Interval, 'when upper included' do
     214    before do
     215      @interval.upper_included = true
     216    end
     217
     218    it 'should be upper uncluded' do
     219      @interval.should be_upper_included
     220    end
     221
     222    it 'should have 10 when upper included' do
     223      @interval.has?(10).should be_true
     224    end
     225
     226    after do
     227      @interval.upper_included = false
     228    end
     229  end
     230
     231  describe Interval, 'when upper unbounded' do
     232    before do
     233      @interval.upper = nil
     234    end
     235
     236    it 'should be upper unbounded' do
     237      @interval.should be_upper_unbounded
     238    end
     239
     240    it 'should have 11' do
     241      @interval.has?(11).should be_true
     242    end
     243
     244    it 'should raise ArgumentError, when upper_included is assigned' do
     245      lambda{
     246        @interval.upper_included = true
     247      }.should raise_error ArgumentError
     248    end
     249
     250    after do
     251      @interval.upper = 10
     252    end
     253  end
     254
     255  describe Interval, 'when lower unbounded' do
     256    before do
     257      @interval.lower = nil
     258    end
     259
     260    it 'should be lower unbounded' do
     261      @interval.should be_lower_unbounded
     262    end
     263
     264    it 'should  have -10' do
     265      @interval.has?(-10).should be_true
     266    end
     267
     268    it 'should raise ArgumentError, when lower_included is assigned' do
     269      lambda{
     270        @interval.lower_included = true
     271      }.should raise_error ArgumentError
     272    end
     273  end
     274
     275  it 'should raise ArgumentError both upper and lower is nil' do
     276    lambda {
     277      Interval.new
     278    }.should raise_error ArgumentError
     279  end
     280end
     281>>>>>>> .r255
  • ruby/branches/0.5/test/unit/open_ehr/assumed_library_types_test.rb

    r191 r256  
    5757
    5858  def test_time_definitions
    59     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::DAYS_IN_LEAP_YEAR, 366
    60     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::DAYS_IN_WEEK, 7
    61     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::DAYS_IN_YEAR, 365
    62     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::HOURS_IN_DAY, 24
    63     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MAX_DAYS_IN_MONTH, 31
    64     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MAX_DAYS_IN_YEAR, 366
    65     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MINUTES_IN_HOUR, 60
    66     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MONTH_IN_YEAR, 12
    67     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::NOMINAL_DAYS_IN_MONTH, 30.42
    68     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::NOMINAL_DAYS_IN_YEAR, 365.24
    69     assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::SECONDS_IN_MINUTE, 60
     59    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::DAYS_IN_LEAP_YEAR, 366
     60    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::DAYS_IN_WEEK, 7
     61    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::DAYS_IN_YEAR, 365
     62    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::HOURS_IN_DAY, 24
     63    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::MAX_DAYS_IN_MONTH, 31
     64    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::MAX_DAYS_IN_YEAR, 366
     65    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::MINUTES_IN_HOUR, 60
     66    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::MONTH_IN_YEAR, 12
     67    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::NOMINAL_DAYS_IN_MONTH, 30.42
     68    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::NOMINAL_DAYS_IN_YEAR, 365.24
     69    assert_equal OpenEhr::AssumedLibraryTypes::TimeDefinitions::SECONDS_IN_MINUTE, 60
    7070  end
    7171
    7272  def test_time_definition_validity
    73     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_year?(2008)
    74     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_year?(-20)
    75     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_year?(0)
     73    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_year?(2008)
     74    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_year?(-20)
     75    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_year?(0)
    7676# today
    77     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,19)
     77    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,6,19)
    7878# test valid_day lower limit
    79     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,0,0)
    80     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,1,1)
    81     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(-1,1,1)
    82     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,1,0)
     79    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(0,0,0)
     80    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(0,1,1)
     81    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(-1,1,1)
     82    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(0,1,0)
    8383# test valid_day upper and lowerlimit of each month
    84     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,0,1)
    85     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,1)
    86     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,0)
    87     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,0,1)
    88     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,31)
    89     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,32)
    90     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,1)
    91     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,0)
    92     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,31)
    93     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,1)
    94     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,0)
    95     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,31)
    96     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,32)
    97     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,1)
    98     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,0)
    99     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,30)
    100     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,31)
    101     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,1)
    102     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,0)
    103     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,31)
    104     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,32)
    105     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,1)
    106     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,0)
    107     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,30)
    108     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,31)
    109     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,1)
    110     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,0)
    111     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,31)
    112     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,32)
    113     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,1)
    114     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,0)
    115     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,31)
    116     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,32)
    117     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,1)
    118     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,0)
    119     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,30)
    120     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,31)
    121     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,1)
    122     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,0)
    123     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,31)
    124     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,32)
    125     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,1)
    126     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,0)
    127     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,30)
    128     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,31)
    129     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,1)
    130     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,0)
    131     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,31)
    132     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,32)
     84    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(0,0,1)
     85    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,1,1)
     86    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,1,0)
     87    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,0,1)
     88    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,1,31)
     89    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,1,32)
     90    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,2,1)
     91    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,2,0)
     92    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,2,31)
     93    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,3,1)
     94    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,3,0)
     95    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,3,31)
     96    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,3,32)
     97    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,4,1)
     98    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,4,0)
     99    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,4,30)
     100    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,4,31)
     101    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,5,1)
     102    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,5,0)
     103    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,5,31)
     104    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,5,32)
     105    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,6,1)
     106    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,6,0)
     107    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,6,30)
     108    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,6,31)
     109    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,7,1)
     110    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,7,0)
     111    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,7,31)
     112    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,7,32)
     113    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,8,1)
     114    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,8,0)
     115    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,8,31)
     116    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,8,32)
     117    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,9,1)
     118    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,9,0)
     119    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,9,30)
     120    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,9,31)
     121    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,10,1)
     122    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,10,0)
     123    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,10,31)
     124    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,10,32)
     125    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,11,1)
     126    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,11,0)
     127    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,11,30)
     128    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,11,31)
     129    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,12,1)
     130    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,12,0)
     131    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,12,31)
     132    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,12,32)
    133133# test valid_day leap year
    134     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(1900,2,28)
    135     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(1900,2,29)
    136     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2000,2,29)
    137     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,29)
     134    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(1900,2,28)
     135    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(1900,2,29)
     136    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2000,2,29)
     137    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,2,29)
    138138# test valid_hour lower limit
    139     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,0)
    140     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(-1,0,0)
    141     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,-1,0)
    142     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,-1)
     139    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(0,0,0)
     140    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(-1,0,0)
     141    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(0,-1,0)
     142    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(0,0,-1)
    143143# test valid_hour upper limit
    144     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,59,0)
    145     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,60,0)
    146     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,59)
    147     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,60)
    148     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(24,0,0)
    149     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(24,0,1)
    150     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(24,1,0)
     144    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(0,59,0)
     145    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(0,60,0)
     146    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(0,0,59)
     147    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(0,0,60)
     148    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(24,0,0)
     149    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(24,0,1)
     150    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_hour?(24,1,0)
    151151# test valid_minute method lower limit
    152     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(0)
    153     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(-1)
     152    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_minute?(0)
     153    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_minute?(-1)
    154154# test valid_minute method upper limit
    155     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(59)
    156     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(60)
     155    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_minute?(59)
     156    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_minute?(60)
    157157# test valid_second method lower limit
    158     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(0)
    159     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(-1)
     158    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_second?(0)
     159    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_second?(-1)
    160160# test valid_second method upper limit
    161     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(59)
    162     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(60)
     161    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_second?(59)
     162    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_second?(60)
    163163# test valid_month method lower limit
    164     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(1)
    165     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(0)
     164    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_month?(1)
     165    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_month?(0)
    166166# test valid_month method upper limit
    167     assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(12)
    168     assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(13)
     167    assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_month?(12)
     168    assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_month?(13)
    169169  end
    170170  def test_iso8601_date
     
    172172    assert_equal 4,@iso8601_date.month
    173173    assert_equal 27,@iso8601_date.day
    174     assert_nothing_raised(Exception){@iso8601_date = OpenEhr::AssumedLibraryTypes::ISO8601_DATE.new('2008')}
     174    assert_nothing_raised(Exception){@iso8601_date = OpenEHR::AssumedLibraryTypes::ISO8601_DATE.new('2008')}
    175175    assert @iso8601_date.day_unknown?
    176176    assert @iso8601_date.month_unknown?
     
    193193    assert !@iso8601_date.is_partial?
    194194    assert_equal "2008-06-14", @iso8601_date.as_string
    195     assert OpenEhr::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("2006-06-14")
    196     assert !OpenEhr::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("ABCDEFG")
     195    assert OpenEHR::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("2006-06-14")
     196    assert !OpenEHR::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("ABCDEFG")
    197197  end
    198198
     
    206206#    assert_nothing_raised(Exception){@iso8601_time = OpenEHR::Assumed_Library_Types::ISO8601_TIME.new('15:55:37.32+0900')}
    207207
    208     assert_nothing_raised(Exception){@iso8601_time = OpenEhr::AssumedLibraryTypes::ISO8601_TIME.new('01')}
     208    assert_nothing_raised(Exception){@iso8601_time = OpenEHR::AssumedLibraryTypes::ISO8601_TIME.new('01')}
    209209    assert_equal 1, @iso8601_time.hour
    210210    assert @iso8601_time.is_partial?
     
    252252    assert @iso8601_time.is_extended?
    253253    assert !@iso8601_time.is_decimal_sign_comma?
    254     assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("012345Z")
    255     assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("012345.67+0900")
    256     assert !OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")
    257     assert !OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")
    258     assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000")
    259     assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000Z")
    260     assert !OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000.011Z")
     254    assert OpenEHR::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("012345Z")
     255    assert OpenEHR::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("012345.67+0900")
     256    assert !OpenEHR::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")
     257    assert !OpenEHR::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")
     258    assert OpenEHR::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000")
     259    assert OpenEHR::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000Z")
     260    assert !OpenEHR::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000.011Z")
    261261  end
    262262
Note: See TracChangeset for help on using the changeset viewer.