[前][次][番号順一覧][スレッド一覧]

ruby-changes:35604

From: suke <ko1@a...>
Date: Mon, 22 Sep 2014 20:01:30 +0900 (JST)
Subject: [ruby-changes:35604] suke:r47686 (trunk): test/win32ole/test_win32ole_variant.rb

suke	2014-09-22 20:01:22 +0900 (Mon, 22 Sep 2014)

  New Revision: 47686

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47686

  Log:
    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.

  Modified files:
    trunk/ChangeLog
    trunk/test/win32ole/test_win32ole_variant.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47685)
+++ ChangeLog	(revision 47686)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Sep 22 20:00:29 2014  Masaki Suketa <masaki.suketa@n...>
+
+	* 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@z...>
 
 	* doc/syntax/methods.rdoc: [DOC] [] and []= methods by @process
Index: test/win32ole/test_win32ole_variant.rb
===================================================================
--- test/win32ole/test_win32ole_variant.rb	(revision 47685)
+++ test/win32ole/test_win32ole_variant.rb	(revision 47686)
@@ -400,13 +400,26 @@ if defined?(WIN32OLE_VARIANT) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole_variant.rb#L400
       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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]