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

* time.c: fix rounding negative float.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-06-27 16:10:46 +00:00
parent accaa5ad3b
commit 1ef7022310
3 changed files with 29 additions and 0 deletions

View file

@ -71,4 +71,25 @@ class TestTime < Test::Unit::TestCase
assert_equal(Time.at(0x7fffffff), Time.at(-0x80000000) - (-0xffffffff))
end
end
def test_at
assert_equal(100000, Time.at(0.1).usec)
assert_equal(10000, Time.at(0.01).usec)
assert_equal(1000, Time.at(0.001).usec)
assert_equal(100, Time.at(0.0001).usec)
assert_equal(10, Time.at(0.00001).usec)
assert_equal(1, Time.at(0.000001).usec)
assert_equal(0, Time.at(1e-7).usec)
assert_equal(0, Time.at(4e-7).usec)
assert_equal(1, Time.at(6e-7).usec)
assert_equal(1, Time.at(14e-7).usec)
assert_equal(2, Time.at(16e-7).usec)
if negative_time_t?
assert_equal(0, Time.at(-1e-7).usec)
assert_equal(0, Time.at(-4e-7).usec)
assert_equal(999999, Time.at(-6e-7).usec)
assert_equal(999999, Time.at(-14e-7).usec)
assert_equal(999998, Time.at(-16e-7).usec)
end
end
end