summaryrefslogtreecommitdiff
path: root/test/-ext-/num2int
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-14 03:47:21 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-14 03:47:21 +0000
commit11137bed53cc5a3431e2db80e27d31629cca4f0e (patch)
tree5e9f46a31fa824d6b37c35c6102c7eb99fa50116 /test/-ext-/num2int
parent15102dacfc2663b94d45a4819ca2a7db62dea8fb (diff)
* test/-ext-/num2int/test_num2int.rb (class TestNum2int):
add FIXNUM tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/num2int')
-rw-r--r--test/-ext-/num2int/test_num2int.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/-ext-/num2int/test_num2int.rb b/test/-ext-/num2int/test_num2int.rb
index 7d021d1..4e2dc37 100644
--- a/test/-ext-/num2int/test_num2int.rb
+++ b/test/-ext-/num2int/test_num2int.rb
@@ -19,10 +19,15 @@ class TestNum2int < Test::Unit::TestCase
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
@@ -73,6 +78,18 @@ class TestNum2int < Test::Unit::TestCase
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 @@ class TestNum2int < Test::Unit::TestCase
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 @@ class TestNum2int < Test::Unit::TestCase
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 @@ class TestNum2int < Test::Unit::TestCase
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