Sha256: 5cc92d727dfb4e655b917fbb80500d537e57efc15c3ffe6c047bca7144fa944e

Contents?: true

Size: 784 Bytes

Versions: 11

Compression:

Stored size: 784 Bytes

Contents

#
# testing ruote
#
# Sat Sep 19 13:27:18 JST 2009
#

require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')

require 'ruote/util/misc'


class UtMiscTest < Test::Unit::TestCase

  def test_narrow_to_number

    assert_equal nil, Ruote.narrow_to_number(nil)
    assert_equal nil, Ruote.narrow_to_number('a')
    assert_equal nil, Ruote.narrow_to_number(Object.new)

    assert_equal 0, Ruote.narrow_to_number(0)
    assert_equal 1, Ruote.narrow_to_number(1)

    assert_equal 0.0, Ruote.narrow_to_number(0.0)
    assert_equal 1.0, Ruote.narrow_to_number(1.0)

    assert_equal 0, Ruote.narrow_to_number('0')
    assert_equal 1, Ruote.narrow_to_number('1')

    assert_equal 0.0, Ruote.narrow_to_number('0.0')
    assert_equal 1.0, Ruote.narrow_to_number('1.0')
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruote-2.1.11 test/unit/ut_15_util.rb
ruote-2.1.10 test/unit/ut_15_util.rb
ruote-2.1.9 test/unit/ut_15_util.rb
ruote-2.1.8 test/unit/ut_15_util.rb
ruote-2.1.7 test/unit/ut_15_util.rb
ruote-2.1.6 test/unit/ut_15_util.rb
ruote-2.1.5 test/unit/ut_15_util.rb
ruote-2.1.4 test/unit/ut_15_util.rb
ruote-2.1.3 test/unit/ut_15_util.rb
ruote-2.1.2 test/unit/ut_15_util.rb
ruote-2.1.1 test/unit/ut_15_util.rb