summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-01 00:13:11 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-01 00:13:11 +0000
commita12a453152dc551a5e4c92038b19594815cbc7d1 (patch)
treead4823acd91dfebe53c8016a6664a96b11a6586b /test
parente3a4e1217f3c57ae42aa7d2aba110d069586145b (diff)
downloadruby-a12a453152dc551a5e4c92038b19594815cbc7d1.tar.gz
add tests for strptime("%s.%N").
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/test_time.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_time.rb b/test/test_time.rb
index ef09f7b920..5f7ff1ad72 100644
--- a/test/test_time.rb
+++ b/test/test_time.rb
@@ -448,6 +448,17 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
assert_equal(true, t.utc?)
end
+ def test_strptime_s_N
+ assert_equal(Time.at(1, 500000), Time.strptime("1.5", "%s.%N"))
+ assert_equal(Time.at(-2, 500000), Time.strptime("-1.5", "%s.%N"))
+ t = Time.strptime("1.000000000001", "%s.%N")
+ assert_equal(1, t.to_i)
+ assert_equal(Rational("0.000000000001"), t.subsec)
+ t = Time.strptime("-1.000000000001", "%s.%N")
+ assert_equal(-2, t.to_i)
+ assert_equal(1-Rational("0.000000000001"), t.subsec)
+ end
+
def test_strptime_Ymd_z
t = Time.strptime('20010203 -0200', '%Y%m%d %z')
assert_equal(2001, t.year)