aboutsummaryrefslogblamecommitdiffstats
path: root/activesupport/test/core_ext/integer_ext_test.rb
blob: e1591089f5a35cbdb02c775e4e452f84f0e6b8f8 (plain) (tree)
1
2
3
4
5
6
7
                       
                                         
 
                                           
                      

                                                          





                                                                              

                     

                                                                              

                                    
                                                                                     
     
   
require 'abstract_unit'
require 'active_support/core_ext/integer'

class IntegerExtTest < Test::Unit::TestCase
  def test_multiple_of
    [ -7, 0, 7, 14 ].each { |i| assert i.multiple_of?(7) }
    [ -7, 7, 14 ].each { |i| assert ! i.multiple_of?(6) }
    # 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

  def test_ordinalize
    # These tests are mostly just to ensure that the ordinalize method exists.
    # Its results are tested comprehensively in the inflector test cases.
    assert_equal '1st', 1.ordinalize
    assert_equal '8th', 8.ordinalize
    1000000000000000000000000000000000000000000000000000000000000000000000.ordinalize
  end
end