diff options
author | siena <siena@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-18 04:00:00 +0000 |
---|---|---|
committer | siena <siena@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-18 04:00:00 +0000 |
commit | 4e880080a725af2f5c052a23635c773f70de315d (patch) | |
tree | 00b2027e843d9ff8e51a85fef2d45b37bbe0ab6d /test | |
parent | 8e8cce4951aa5aa5def7335e72b13893aff3d2e0 (diff) | |
download | ruby-4e880080a725af2f5c052a23635c773f70de315d.tar.gz |
* 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
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_time.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb new file mode 100644 index 0000000000..bcb480def2 --- /dev/null +++ b/test/ruby/test_time.rb @@ -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 |