2008-01-05 13:31:04 +00:00
|
|
|
require 'abstract_unit'
|
2009-03-29 06:56:14 +00:00
|
|
|
require 'active_support/core_ext/integer'
|
2005-04-05 16:54:17 +00:00
|
|
|
|
2005-07-19 12:58:01 +00:00
|
|
|
class IntegerExtTest < Test::Unit::TestCase
|
2005-06-21 07:00:28 +00:00
|
|
|
def test_multiple_of
|
2005-07-19 12:58:01 +00:00
|
|
|
[ -7, 0, 7, 14 ].each { |i| assert i.multiple_of?(7) }
|
|
|
|
[ -7, 7, 14 ].each { |i| assert ! i.multiple_of?(6) }
|
2009-11-15 00:22:26 +00:00
|
|
|
|
|
|
|
# test the 0 edge case
|
|
|
|
assert 0.multiple_of?(0)
|
|
|
|
assert !5.multiple_of?(0)
|
|
|
|
|
2005-06-21 07:00:28 +00:00
|
|
|
# test with a prime
|
|
|
|
assert !22953686867719691230002707821868552601124472329079.multiple_of?(2)
|
|
|
|
assert !22953686867719691230002707821868552601124472329079.multiple_of?(3)
|
|
|
|
assert !22953686867719691230002707821868552601124472329079.multiple_of?(5)
|
|
|
|
assert !22953686867719691230002707821868552601124472329079.multiple_of?(7)
|
|
|
|
end
|
2005-07-18 02:16:17 +00:00
|
|
|
|
|
|
|
def test_ordinalize
|
2009-01-18 18:10:58 +00:00
|
|
|
# These tests are mostly just to ensure that the ordinalize method exists.
|
|
|
|
# Its results are tested comprehensively in the inflector test cases.
|
2005-07-18 02:16:17 +00:00
|
|
|
assert_equal '1st', 1.ordinalize
|
|
|
|
assert_equal '8th', 8.ordinalize
|
2005-07-19 12:58:01 +00:00
|
|
|
1000000000000000000000000000000000000000000000000000000000000000000000.ordinalize
|
2005-07-18 02:16:17 +00:00
|
|
|
end
|
2005-04-05 16:54:17 +00:00
|
|
|
end
|