Sha256: 527094f87b3a94e9c8b181dc4586e5bfa692bd8fbc4af72d888ba1eb84afe9d6

Contents?: true

Size: 956 Bytes

Versions: 48

Compression:

Stored size: 956 Bytes

Contents

require 'test_helper'
require 'tins/xt'

module Tins
  class RoundTest < Test::Unit::TestCase

    def test_standard
      assert_equal(1, 1.round)
      assert_equal(-1, -1.round)
      assert_equal(2, 1.5.round)
      assert_kind_of Integer, 1.5.round
      assert_equal(-1, -1.4.round)
      assert_equal(-2, -1.5.round)
    end

    def test_inclusion
      assert_equal(10, 12.round(-1))
      assert_kind_of Integer, 12.round(-1)
      assert_equal(-10, -12.round(-1))
      assert_raises(ArgumentError) { 12.round(-2) }
      assert_raises(ArgumentError) { -12.round(-2) }
      assert_in_delta(1.6, 1.55.round(1), 1E-1)
      assert_kind_of Float, 1.55.round(1)
      assert_equal(2, 1.55.round(0))
      assert_in_delta(-1.5, -1.45.round(1), 1E-1)
      assert_equal(-1, -1.45.round(0))
      assert_in_delta(-1.6, -1.55.round(1), 1E-1)
      assert_equal(-2, -1.55.round(0))
      assert_in_delta(-1.55, -1.55.round(999), 1E-2)
    end
  end
end

Version data entries

48 entries across 47 versions & 3 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/tests/round_test.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/tests/round_test.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/tins-0.13.2/tests/round_test.rb
tdiary-5.0.8 vendor/bundle/gems/tins-0.13.2/tests/round_test.rb
tins-1.3.0 tests/round_test.rb
tins-1.2.0 tests/round_test.rb
tins-1.1.0 tests/round_test.rb
tins-1.0.1 tests/round_test.rb
tins-1.0.0 tests/round_test.rb
tins-0.13.2 tests/round_test.rb
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/tins-0.13.1/tests/round_test.rb
tins-0.13.1 tests/round_test.rb
tins-0.13.0 tests/round_test.rb
tins-0.12.0 tests/round_test.rb
tins-0.11.0 tests/round_test.rb
tins-0.10.0 tests/round_test.rb
tins-0.9.0 tests/round_test.rb
tins-0.8.4 tests/round_test.rb
tins-0.8.3 tests/round_test.rb
tins-0.8.2 tests/round_test.rb