Sha256: 62c16f5efea1757c2ed15450778bdf14156d04d29e515a8cee20a35e81d9a11c

Contents?: true

Size: 743 Bytes

Versions: 4

Compression:

Stored size: 743 Bytes

Contents

require 'helper'
require 'toolbox/integer'

class TestToolboxInteger < Test::Unit::TestCase

  should 'String is a valid integer' do
    (0..1000).each do |integer|
      assert_equal true, integer.to_s.is_i?
    end
  end

  should 'String is a negative number' do
    (-1000..0).each do |integer|
      assert_equal true, integer.to_s.is_i?
    end
  end

  should 'An actual Integer.to_i should return true' do
    assert_equal true, 1.is_i?
  end

  should 'String is a double value' do
    ['1.0', '-1.0', '3.1415'].each do |double|
      assert_equal false, double.is_i?
    end
  end

  should 'String is not a number' do
    ['foo', 'bar', 'one', '1 another'].each do |string|
      assert_equal false, string.is_i?
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-development-toolbox-1.4.0 test/test_toolbox-integer.rb
ruby-development-toolbox-1.3.2 test/test_toolbox-integer.rb
ruby-development-toolbox-1.3.1 test/test_toolbox-integer.rb
ruby-development-toolbox-1.3.0 test/test_toolbox-integer.rb