ruby-changes:37709
From: akr <ko1@a...>
Date: Sun, 1 Mar 2015 09:13:19 +0900 (JST)
Subject: [ruby-changes:37709] akr:r49790 (trunk): add tests for strptime("%s.%N").
akr 2015-03-01 09:13:11 +0900 (Sun, 01 Mar 2015) New Revision: 49790 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49790 Log: add tests for strptime("%s.%N"). Modified files: trunk/test/test_time.rb Index: test/test_time.rb =================================================================== --- test/test_time.rb (revision 49789) +++ test/test_time.rb (revision 49790) @@ -448,6 +448,17 @@ class TestTimeExtension < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/test_time.rb#L448 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/