Changeset 256
 Timestamp:
 Sep 11, 2009, 1:10:23 AM (11 years ago)
 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 81 81 end # end of Interval 82 82 83 class T IME_DEFINITIONS< Any83 class TimeDefinitions < Any 84 84 DAYS_IN_LEAP_YEAR = 366 85 85 DAYS_IN_WEEK = 7 … … 120 120 mo >= 1 and mo <= MONTH_IN_YEAR 121 121 end 122 end # end of T IME_DEFINITIONS123 124 module ISO8601 _DATE_MODULE122 end # end of TimeDefinitions 123 124 module ISO8601DateModule 125 125 attr_reader :year, :month, :day 126 126 127 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 128 131 @year = year 129 132 end 133 130 134 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) 132 136 @month = month 133 137 end 134 138 135 139 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) 137 141 @day = day 138 142 end … … 174 178 end 175 179 176 class ISO8601 _DATE < TIME_DEFINITIONS177 include ISO8601 _DATE_MODULE180 class ISO8601Date < TimeDefinitions 181 include ISO8601DateModule 178 182 def initialize(string) 179 183 /(\d{4})(?:(\d{2})(?:(\d{2})?)?)?/ =~ string … … 205 209 end # end of ISO8601_DATE 206 210 207 module ISO8601 _TIME_MODULE211 module ISO8601TimeModule 208 212 attr_reader :hour, :minute, :second, :fractional_second, :timezone 209 213 … … 289 293 end 290 294 291 class ISO8601 _TIME < TIME_DEFINITIONS292 include ISO8601 _TIME_MODULE295 class ISO8601Time < TimeDefinitions 296 include ISO8601TimeModule 293 297 def initialize(string) 294 298 /(\d{2}):?(\d{2})?(:?)(\d{2})?((\.,)(\d+))?(Z([+](\d{2}):?(\d{2})))?/ =~ string … … 361 365 end # end of ISO8601_TIME 362 366 363 module ISO8601 _DATE_TIME_MODULE364 include ISO8601 _DATE_MODULE, ISO8601_TIME_MODULE367 module ISO8601DateTimeModule 368 include ISO8601DateModule, ISO8601TimeModule 365 369 def as_string 366 370 if (!@year.nil? and !@month.nil? and !@day.nil?) … … 390 394 end 391 395 392 class ISO8601 _DATE_TIME < ISO8601_DATE393 include ISO8601 _DATE_TIME_MODULE396 class ISO8601DateTime < ISO8601Date 397 include ISO8601DateTimeModule 394 398 def initialize(string) 395 399 /(\d{4})(?:(\d{2})(?:(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z([+]\d{2}):?(\d{2}))?)?)?)?/ =~ string … … 544 548 end 545 549 end 546 class ISO8601_DURATION < T IME_DEFINITIONS550 class ISO8601_DURATION < TimeDefinitions 547 551 include ISO8601_DURATION_MODULE 548 552 def initialize(str) 
ruby/branches/0.5/spec/lib/open_ehr/assumed_library_types/interval_spec.rb
r255 r256 1 <<<<<<< .mine 1 2 require File.dirname(__FILE__) + '/../../../spec_helper' 2 3 include OpenEHR::AssumedLibraryTypes … … 48 49 end 49 50 50 it 'should havenot have 1' do51 it 'should not have 1' do 51 52 @interval.has?(1).should_not be_true 52 53 end … … 138 139 end 139 140 end 141 ======= 142 require File.dirname(__FILE__) + '/../../../spec_helper' 143 include OpenEHR::AssumedLibraryTypes 144 145 describe 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 280 end 281 >>>>>>> .r255 
ruby/branches/0.5/test/unit/open_ehr/assumed_library_types_test.rb
r191 r256 57 57 58 58 def test_time_definitions 59 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::DAYS_IN_LEAP_YEAR, 36660 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::DAYS_IN_WEEK, 761 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::DAYS_IN_YEAR, 36562 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::HOURS_IN_DAY, 2463 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::MAX_DAYS_IN_MONTH, 3164 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::MAX_DAYS_IN_YEAR, 36665 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::MINUTES_IN_HOUR, 6066 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::MONTH_IN_YEAR, 1267 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::NOMINAL_DAYS_IN_MONTH, 30.4268 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::NOMINAL_DAYS_IN_YEAR, 365.2469 assert_equal OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS::SECONDS_IN_MINUTE, 6059 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 70 70 end 71 71 72 72 def test_time_definition_validity 73 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_year?(2008)74 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_year?(20)75 assert OpenEhr::AssumedLibraryTypes::T IME_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) 76 76 # today 77 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,6,19)77 assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_day?(2008,6,19) 78 78 # test valid_day lower limit 79 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(0,0,0)80 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(0,1,1)81 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(1,1,1)82 assert !OpenEhr::AssumedLibraryTypes::T IME_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) 83 83 # test valid_day upper and lowerlimit of each month 84 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(0,0,1)85 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,1,1)86 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,1,0)87 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,0,1)88 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,1,31)89 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,1,32)90 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,2,1)91 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,2,0)92 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,2,31)93 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,3,1)94 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,3,0)95 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,3,31)96 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,3,32)97 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,4,1)98 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,4,0)99 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,4,30)100 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,4,31)101 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,5,1)102 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,5,0)103 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,5,31)104 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,5,32)105 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,6,1)106 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,6,0)107 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,6,30)108 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,6,31)109 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,7,1)110 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,7,0)111 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,7,31)112 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,7,32)113 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,8,1)114 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,8,0)115 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,8,31)116 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,8,32)117 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,9,1)118 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,9,0)119 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,9,30)120 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,9,31)121 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,10,1)122 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,10,0)123 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,10,31)124 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,10,32)125 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,11,1)126 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,11,0)127 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,11,30)128 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,11,31)129 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,12,1)130 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,12,0)131 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2008,12,31)132 assert !OpenEhr::AssumedLibraryTypes::T IME_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) 133 133 # test valid_day leap year 134 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(1900,2,28)135 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(1900,2,29)136 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_day?(2000,2,29)137 assert OpenEhr::AssumedLibraryTypes::T IME_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) 138 138 # test valid_hour lower limit 139 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_hour?(0,0,0)140 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_hour?(1,0,0)141 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_hour?(0,1,0)142 assert !OpenEhr::AssumedLibraryTypes::T IME_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) 143 143 # test valid_hour upper limit 144 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_hour?(0,59,0)145 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_hour?(0,60,0)146 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_hour?(0,0,59)147 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_hour?(0,0,60)148 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_hour?(24,0,0)149 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_hour?(24,0,1)150 assert !OpenEhr::AssumedLibraryTypes::T IME_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) 151 151 # test valid_minute method lower limit 152 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_minute?(0)153 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_minute?(1)152 assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_minute?(0) 153 assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_minute?(1) 154 154 # test valid_minute method upper limit 155 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_minute?(59)156 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_minute?(60)155 assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_minute?(59) 156 assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_minute?(60) 157 157 # test valid_second method lower limit 158 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_second?(0)159 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_second?(1)158 assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_second?(0) 159 assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_second?(1) 160 160 # test valid_second method upper limit 161 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_second?(59)162 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_second?(60)161 assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_second?(59) 162 assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_second?(60) 163 163 # test valid_month method lower limit 164 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_month?(1)165 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_month?(0)164 assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_month?(1) 165 assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_month?(0) 166 166 # test valid_month method upper limit 167 assert OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_month?(12)168 assert !OpenEhr::AssumedLibraryTypes::T IME_DEFINITIONS.valid_month?(13)167 assert OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_month?(12) 168 assert !OpenEhr::AssumedLibraryTypes::TimeDefinitions.valid_month?(13) 169 169 end 170 170 def test_iso8601_date … … 172 172 assert_equal 4,@iso8601_date.month 173 173 assert_equal 27,@iso8601_date.day 174 assert_nothing_raised(Exception){@iso8601_date = OpenE hr::AssumedLibraryTypes::ISO8601_DATE.new('2008')}174 assert_nothing_raised(Exception){@iso8601_date = OpenEHR::AssumedLibraryTypes::ISO8601_DATE.new('2008')} 175 175 assert @iso8601_date.day_unknown? 176 176 assert @iso8601_date.month_unknown? … … 193 193 assert !@iso8601_date.is_partial? 194 194 assert_equal "20080614", @iso8601_date.as_string 195 assert OpenE hr::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("20060614")196 assert !OpenE hr::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("ABCDEFG")195 assert OpenEHR::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("20060614") 196 assert !OpenEHR::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("ABCDEFG") 197 197 end 198 198 … … 206 206 # assert_nothing_raised(Exception){@iso8601_time = OpenEHR::Assumed_Library_Types::ISO8601_TIME.new('15:55:37.32+0900')} 207 207 208 assert_nothing_raised(Exception){@iso8601_time = OpenE hr::AssumedLibraryTypes::ISO8601_TIME.new('01')}208 assert_nothing_raised(Exception){@iso8601_time = OpenEHR::AssumedLibraryTypes::ISO8601_TIME.new('01')} 209 209 assert_equal 1, @iso8601_time.hour 210 210 assert @iso8601_time.is_partial? … … 252 252 assert @iso8601_time.is_extended? 253 253 assert !@iso8601_time.is_decimal_sign_comma? 254 assert OpenE hr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("012345Z")255 assert OpenE hr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("012345.67+0900")256 assert !OpenE hr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")257 assert !OpenE hr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")258 assert OpenE hr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000")259 assert OpenE hr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000Z")260 assert !OpenE hr::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") 261 261 end 262 262
Note: See TracChangeset
for help on using the changeset viewer.