1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/ruby/test_time.rb
akira 8ccba1d12f * test/ruby/test_time.rb: added tests for [ruby-dev:22614] and
[ruby-dev:22617].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-01-19 07:32:47 +00:00

26 lines
885 B
Ruby

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))
assert_equal(0, (Time.at(1.1) + 0.9).usec)
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))
assert_equal(900000, (Time.at(1.1) - 0.2).usec)
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