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

ruby-changes:21692

From: kosaki <ko1@a...>
Date: Mon, 14 Nov 2011 12:47:31 +0900 (JST)
Subject: [ruby-changes:21692] kosaki:r33741 (trunk): * test/-ext-/num2int/test_num2int.rb (class TestNum2int):

kosaki	2011-11-14 12:47:21 +0900 (Mon, 14 Nov 2011)

  New Revision: 33741

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

  Log:
    * test/-ext-/num2int/test_num2int.rb (class TestNum2int):
      add FIXNUM tests.

  Modified files:
    trunk/ChangeLog
    trunk/test/-ext-/num2int/test_num2int.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33740)
+++ ChangeLog	(revision 33741)
@@ -1,3 +1,8 @@
+Sun Nov 13 10:22:44 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* test/-ext-/num2int/test_num2int.rb (class TestNum2int):
+	  add FIXNUM tests.
+
 Sun Nov 13 09:57:29 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* numeric.c (check_uint): fix off-by-one bug of NUM2UINT.
Index: test/-ext-/num2int/test_num2int.rb
===================================================================
--- test/-ext-/num2int/test_num2int.rb	(revision 33740)
+++ test/-ext-/num2int/test_num2int.rb	(revision 33741)
@@ -19,11 +19,16 @@
     LONG_MIN = -9223372036854775808
     ULONG_MAX = 18446744073709551615
   end
+  ULONG_HALF = ULONG_MAX - LONG_MAX
 
   LLONG_MAX = 9223372036854775807
   LLONG_MIN = -9223372036854775808
   ULLONG_MAX = 18446744073709551615
+  ULLONG_HALF = ULLONG_MAX - LLONG_MAX # 0x8000000000000000
 
+  FIXNUM_MAX = LONG_MAX/2
+  FIXNUM_MIN = LONG_MIN/2
+
   def test_num2int
     assert_output(INT_MIN.to_s) do
       Num2int.print_num2int(INT_MIN)
@@ -73,6 +78,18 @@
     assert_raise(RangeError) do
       Num2int.print_num2long(LONG_MAX+1)
     end
+    assert_output(FIXNUM_MIN.to_s) do
+      Num2int.print_num2long(FIXNUM_MIN)
+    end
+    assert_output((FIXNUM_MIN-1).to_s) do
+      Num2int.print_num2long(FIXNUM_MIN-1)
+    end
+    assert_output(FIXNUM_MAX.to_s) do
+      Num2int.print_num2long(FIXNUM_MAX)
+    end
+    assert_output((FIXNUM_MAX+1).to_s) do
+      Num2int.print_num2long(FIXNUM_MAX+1)
+    end
   end
 
   def test_num2ulong
@@ -94,6 +111,18 @@
     assert_raise(RangeError) do
       Num2int.print_num2ulong(ULONG_MAX+1)
     end
+    assert_output((ULONG_HALF+FIXNUM_MAX+1).to_s) do
+      Num2int.print_num2ulong(FIXNUM_MIN)
+    end
+    assert_output((ULONG_HALF+FIXNUM_MAX).to_s) do
+      Num2int.print_num2ulong(FIXNUM_MIN-1)
+    end
+    assert_output(FIXNUM_MAX.to_s) do
+      Num2int.print_num2ulong(FIXNUM_MAX)
+    end
+    assert_output((FIXNUM_MAX+1).to_s) do
+      Num2int.print_num2ulong(FIXNUM_MAX+1)
+    end
   end
 
   def test_num2ll
@@ -109,6 +138,18 @@
     assert_raise(RangeError) do
       Num2int.print_num2ll(LLONG_MAX+1)
     end
+    assert_output(FIXNUM_MIN.to_s) do
+      Num2int.print_num2ll(FIXNUM_MIN)
+    end
+    assert_output((FIXNUM_MIN-1).to_s) do
+      Num2int.print_num2ll(FIXNUM_MIN-1)
+    end
+    assert_output(FIXNUM_MAX.to_s) do
+      Num2int.print_num2ll(FIXNUM_MAX)
+    end
+    assert_output((FIXNUM_MAX+1).to_s) do
+      Num2int.print_num2ll(FIXNUM_MAX+1)
+    end
   end
 
   def test_num2ull
@@ -139,6 +180,18 @@
     assert_raise(RangeError) do
       Num2int.print_num2ull(ULLONG_MAX+1)
     end
+    assert_output((ULLONG_HALF+FIXNUM_MAX+1).to_s) do
+      Num2int.print_num2ull(FIXNUM_MIN)
+    end
+    assert_output((ULLONG_HALF+FIXNUM_MAX).to_s) do
+      Num2int.print_num2ull(FIXNUM_MIN-1)
+    end
+    assert_output(FIXNUM_MAX.to_s) do
+      Num2int.print_num2ull(FIXNUM_MAX)
+    end
+    assert_output((FIXNUM_MAX+1).to_s) do
+      Num2int.print_num2ull(FIXNUM_MAX+1)
+    end
   end
 end
 

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

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