From afe1bbeb4e07cbdfa706e4be551c5980978d65f1 Mon Sep 17 00:00:00 2001 From: suke Date: Mon, 22 Sep 2014 11:01:22 +0000 Subject: test/win32ole/test_win32ole_variant.rb (test_conversion_time2date_with_msec): test by using only assert_in_delta to avoid to fail when converting Time object with 999999999 nanoseconds into VT_DATE Variant. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ test/win32ole/test_win32ole_variant.rb | 21 +++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index efb4c8f3a8..0a3b352c3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Sep 22 20:00:29 2014 Masaki Suketa + + * test/win32ole/test_win32ole_variant.rb + (test_conversion_time2date_with_msec): test by using only + assert_in_delta to avoid to fail when converting Time object with + 999999999 nanoseconds into VT_DATE Variant. + Mon Sep 22 19:49:12 2014 Zachary Scott * doc/syntax/methods.rdoc: [DOC] [] and []= methods by @process diff --git a/test/win32ole/test_win32ole_variant.rb b/test/win32ole/test_win32ole_variant.rb index 3b6fba7606..9583a0157e 100644 --- a/test/win32ole/test_win32ole_variant.rb +++ b/test/win32ole/test_win32ole_variant.rb @@ -400,13 +400,26 @@ if defined?(WIN32OLE_VARIANT) t0 = Time.new(2014, 8, 27, 12, 34, 56) t0 += 0.789 t1 = WIN32OLE_VARIANT.new(t0).value - assert_equal("2014-08-27 12:34:56", t1.strftime('%Y-%m-%d %H:%M:%S')) - assert_in_delta(0.789, t1.nsec / 1000000000.0, 0.001) + + # The t0.nsec is 789000000 and t1.nsec is 789000465 + # because of error range by conversion Time between VT_DATE Variant. + # So check t1 and t0 are in error by less than one millisecond. + msg = "Expected:#{t0.strftime('%Y-%m-%dT%H:%M:%S.%N')} but was:#{t1.strftime('%Y-%m-%dT%H:%M:%S.%N')}" + assert_in_delta(t0, t1, 0.001, msg) + + t0 = Time.new(2014, 8, 27, 12, 34, 56) + t0 += 0.999999999 + t1 = WIN32OLE_VARIANT.new(t0).value + msg = "Expected:#{t0.strftime('%Y-%m-%dT%H:%M:%S.%N')} but was:#{t1.strftime('%Y-%m-%dT%H:%M:%S.%N')}" + + # The t0 is "2014/08/27 12:34.56.999999999" and + # the t1 is "2014/08/27 12:34:57.000000628" + assert_in_delta(t0, t1, 0.001, msg) t0 = Time.now t1 = WIN32OLE_VARIANT.new(t0).value - assert_equal(t0.strftime('%Y-%m-%d %H:%M:%S'), t1.strftime('%Y-%m-%d %H:%M:%S')) - assert_in_delta(t0.nsec/1000000000.0, t1.nsec / 1000000000.0, 0.001) + msg = "Expected:#{t0.strftime('%Y-%m-%dT%H:%M:%S.%N')} but was:#{t1.strftime('%Y-%m-%dT%H:%M:%S.%N')}" + assert_in_delta(t0, t1, 0.001, msg) end # this test failed because of VariantTimeToSystemTime -- cgit v1.2.3