1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/test_time.rb: new test case to test Time#[+-].

* time.c (time_plus, time_minus): fix RangeError for a negative
  argument in environments whose time_t is unsigned. [ruby-dev:22608]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
siena 2004-01-18 04:00:00 +00:00
parent 8e8cce4951
commit 4e880080a7

24
test/ruby/test_time.rb Normal file
View file

@ -0,0 +1,24 @@
require 'test/unit'
class TestTime < Test::Unit::TestCase
def test_time_add()
assert_equal(Time.utc(2000, 3, 21, 3, 30) + 3 * 3600,
Time.utc(2000, 3, 21, 6, 30))
assert_equal(Time.utc(2000, 3, 21, 3, 30) + (-3 * 3600),
Time.utc(2000, 3, 21, 0, 30))
end
def test_time_subt()
assert_equal(Time.utc(2000, 3, 21, 3, 30) - 3 * 3600,
Time.utc(2000, 3, 21, 0, 30))
assert_equal(Time.utc(2000, 3, 21, 3, 30) - (-3 * 3600),
Time.utc(2000, 3, 21, 6, 30))
end
def test_time_time()
assert_equal(Time.utc(2000, 3, 21, 3, 30) \
-Time.utc(2000, 3, 21, 0, 30), 3*3600)
assert_equal(Time.utc(2000, 3, 21, 0, 30) \
-Time.utc(2000, 3, 21, 3, 30), -3*3600)
end
end