aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-22 11:01:22 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-22 11:01:22 +0000
commitafe1bbeb4e07cbdfa706e4be551c5980978d65f1 (patch)
tree5785a47963094cba35ef07372271f04c38fcb420
parentf13f9f694615780ef0d3d7741e84892d572d5be9 (diff)
downloadruby-afe1bbeb4e07cbdfa706e4be551c5980978d65f1.tar.gz
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
-rw-r--r--ChangeLog7
-rw-r--r--test/win32ole/test_win32ole_variant.rb21
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 <masaki.suketa@nifty.ne.jp>
+
+ * 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 <e@zzak.io>
* 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